Improved debug output.
This commit is contained in:
parent
1e43bde447
commit
9b431deea3
2 changed files with 19 additions and 9 deletions
|
@ -4,13 +4,16 @@ class Channel::IMAP < Channel::EmailParser
|
||||||
include UserInfo
|
include UserInfo
|
||||||
|
|
||||||
def fetch (channel)
|
def fetch (channel)
|
||||||
puts 'fetching imap'
|
puts "fetching imap (#{channel[:options][:host]}/#{channel[:options][:user]})"
|
||||||
|
|
||||||
imap = Net::IMAP.new(channel[:options][:host], 993, true )
|
imap = Net::IMAP.new(channel[:options][:host], 993, true )
|
||||||
imap.authenticate('LOGIN', channel[:options][:user], channel[:options][:password])
|
imap.authenticate('LOGIN', channel[:options][:user], channel[:options][:password])
|
||||||
imap.select('INBOX')
|
imap.select('INBOX')
|
||||||
count = 0
|
count = 0
|
||||||
|
count_all = imap.search(['ALL']).count
|
||||||
imap.search(['ALL']).each do |message_id|
|
imap.search(['ALL']).each do |message_id|
|
||||||
|
count += 1
|
||||||
|
puts " - message #{count.to_s}/#{count_all.to_s}"
|
||||||
msg = imap.fetch(message_id,'RFC822')[0].attr['RFC822']
|
msg = imap.fetch(message_id,'RFC822')[0].attr['RFC822']
|
||||||
# puts msg.to_s
|
# puts msg.to_s
|
||||||
|
|
||||||
|
@ -18,11 +21,13 @@ class Channel::IMAP < Channel::EmailParser
|
||||||
if parse(channel, msg)
|
if parse(channel, msg)
|
||||||
imap.store(message_id, "+FLAGS", [:Deleted])
|
imap.store(message_id, "+FLAGS", [:Deleted])
|
||||||
end
|
end
|
||||||
count += 1
|
|
||||||
end
|
end
|
||||||
imap.expunge()
|
imap.expunge()
|
||||||
imap.disconnect()
|
imap.disconnect()
|
||||||
puts "#{count.to_s} mails fetched. done."
|
if count == 0
|
||||||
|
puts " - no message"
|
||||||
|
end
|
||||||
|
puts "done"
|
||||||
end
|
end
|
||||||
def send(attr, notification = false)
|
def send(attr, notification = false)
|
||||||
channel = Channel.where( :area => 'Email::Outbound', :active => true ).first
|
channel = Channel.where( :area => 'Email::Outbound', :active => true ).first
|
||||||
|
|
|
@ -4,22 +4,27 @@ class Channel::POP3 < Channel::EmailParser
|
||||||
include UserInfo
|
include UserInfo
|
||||||
|
|
||||||
def fetch (channel)
|
def fetch (channel)
|
||||||
puts 'fetching pop3'
|
puts "fetching pop3 (#{channel[:options][:host]}/#{channel[:options][:user]})"
|
||||||
|
|
||||||
pop = Net::POP3.new( channel[:options][:host], 995 )
|
pop = Net::POP3.new( channel[:options][:host], 995 )
|
||||||
pop.enable_ssl
|
pop.enable_ssl
|
||||||
pop.start( channel[:options][:user], channel[:options][:password] )
|
pop.start( channel[:options][:user], channel[:options][:password] )
|
||||||
count = 0
|
count = 0
|
||||||
|
count_all = pop.mails.size
|
||||||
pop.each_mail do |m|
|
pop.each_mail do |m|
|
||||||
|
count += 1
|
||||||
|
puts " - message #{count.to_s}/#{count_all.to_s}"
|
||||||
|
|
||||||
# delete email from server after article was created
|
# delete email from server after article was created
|
||||||
if parse(channel, m.pop)
|
if parse(channel, m.pop)
|
||||||
m.delete
|
m.delete
|
||||||
end
|
end
|
||||||
count += 1
|
|
||||||
end
|
end
|
||||||
pop.finish
|
pop.finish
|
||||||
puts "#{count.to_s} mails popped. done."
|
if count == 0
|
||||||
|
puts " - no message"
|
||||||
|
end
|
||||||
|
puts "done"
|
||||||
end
|
end
|
||||||
def send(attr, notification = false)
|
def send(attr, notification = false)
|
||||||
channel = Channel.where( :area => 'Email::Outbound', :active => true ).first
|
channel = Channel.where( :area => 'Email::Outbound', :active => true ).first
|
||||||
|
|
Loading…
Reference in a new issue