mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-24 08:09:13 -05:00
f0a122a66c
introduce new setting email_always, that will force emails to send to users regardless of presence on site
35 lines
878 B
Ruby
35 lines
878 B
Ruby
#
|
|
# Connects to a mailbox and checks for replies
|
|
#
|
|
require 'net/pop'
|
|
require_dependency 'email/receiver'
|
|
|
|
module Jobs
|
|
class PollMailbox < Jobs::Scheduled
|
|
recurrence { minutely }
|
|
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|
|
|
if Email::Receiver.new(mail.pop).process == Email::Receiver.results[:processed]
|
|
mail.delete
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|