Fix mail verify.
This commit is contained in:
parent
59b23772c3
commit
4e7be83b86
|
@ -32,13 +32,20 @@ namespace :epaper do
|
|||
Thread.new do
|
||||
tmp = []
|
||||
site = Site.first
|
||||
if site[:gmail_login_flag]
|
||||
@address = '127.0.0.1'
|
||||
@port = 25
|
||||
tls = false
|
||||
from_addr = site.gmail
|
||||
else
|
||||
@address = site['site_settings']['address']
|
||||
@port = (site['site_settings']['port'].to_i rescue 587)
|
||||
tls = (site['site_settings']['enable_starttls_auto'] == "1")
|
||||
from_addr = site['site_settings']['service_email']
|
||||
end
|
||||
@open_timeout = 10
|
||||
@read_timeout = 60
|
||||
@debug_output = nil
|
||||
tls = (site['site_settings']['enable_starttls_auto'] == "1")
|
||||
from_addr = site['site_settings']['service_email']
|
||||
emails_valid.each_slice(mail_limit).each do |slice_emails|
|
||||
invalid_mails = epaper_verify_email(from_addr,slice_emails,tls)
|
||||
deliver_emails = slice_emails - invalid_mails
|
||||
|
@ -49,7 +56,7 @@ namespace :epaper do
|
|||
puts "Emails will be sent at #{email_sentdate.strftime("%Y-%m-%d %H:%M")}"
|
||||
else
|
||||
email.deliver
|
||||
puts "Sending #{deliver_emails.count} emails"
|
||||
puts "Sending #{deliver_emails.count} emails: #{deliver_emails}"
|
||||
end
|
||||
rescue => e
|
||||
puts [deliver_emails.inspect,e,e.backtrace]
|
||||
|
@ -72,9 +79,15 @@ namespace :epaper do
|
|||
end
|
||||
end
|
||||
def epaper_verify_email(from_addr,check_emails,tls) #true if check_email is ok
|
||||
return [] if @mail_server_broken
|
||||
begin
|
||||
s = Timeout.timeout(@open_timeout, Net::OpenTimeout) do
|
||||
TCPSocket.open(@address, @port)
|
||||
end
|
||||
rescue => e
|
||||
puts [e.to_s, e.backtrace]
|
||||
@mail_server_broken = true
|
||||
end
|
||||
@socket = epaper_new_internet_message_io(tls ? epaper_tlsconnect(s) : s)
|
||||
res = epaper_get_response("MAIL FROM:<#{from_addr}>")
|
||||
invalid_emails = []
|
||||
|
|
Loading…
Reference in New Issue