2013-06-13 18:11:10 -04:00
|
|
|
#
|
|
|
|
# Connects to a mailbox and checks for replies
|
|
|
|
#
|
|
|
|
require 'net/pop'
|
|
|
|
require_dependency 'email/receiver'
|
|
|
|
|
|
|
|
module Jobs
|
2013-08-07 13:25:05 -04:00
|
|
|
class PollMailbox < Jobs::Scheduled
|
|
|
|
recurrence { minutely }
|
2013-06-13 18:11:10 -04:00
|
|
|
sidekiq_options retry: false
|
|
|
|
|
|
|
|
def execute(args)
|
|
|
|
if SiteSetting.pop3s_polling_enabled?
|
|
|
|
poll_pop3s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def poll_pop3s
|
|
|
|
Net::POP3.enable_ssl(OpenSSL::SSL::VERIFY_NONE)
|
|
|
|
Net::POP3.start(SiteSetting.pop3s_polling_host,
|
|
|
|
SiteSetting.pop3s_polling_port,
|
|
|
|
SiteSetting.pop3s_polling_username,
|
|
|
|
SiteSetting.pop3s_polling_password) do |pop|
|
|
|
|
unless pop.mails.empty?
|
|
|
|
pop.each do |mail|
|
2013-07-27 19:53:54 -04:00
|
|
|
if Email::Receiver.new(mail.pop).process == Email::Receiver.results[:processed]
|
|
|
|
mail.delete
|
|
|
|
end
|
2013-06-13 18:11:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|