Fix rake function repeat name.
This commit is contained in:
parent
80e1362ab6
commit
8a49e8fd0d
|
@ -35,7 +35,7 @@ namespace :epaper do
|
||||||
tls = (site['site_settings']['enable_starttls_auto'] == "1")
|
tls = (site['site_settings']['enable_starttls_auto'] == "1")
|
||||||
from_addr = site['site_settings']['service_email']
|
from_addr = site['site_settings']['service_email']
|
||||||
emails_valid.each_slice(mail_limit).each do |slice_emails|
|
emails_valid.each_slice(mail_limit).each do |slice_emails|
|
||||||
invalid_mails = verify_email(from_addr,slice_emails,tls)
|
invalid_mails = epaper_verify_email(from_addr,slice_emails,tls)
|
||||||
deliver_emails = slice_emails - invalid_mails
|
deliver_emails = slice_emails - invalid_mails
|
||||||
email = Email.new(:mail_subject => paper.sending_title, :mail_lang => args[:locale], :template => "admin/e_paper_criterias/emailer", :template_data => {"paper_id" => paper.id, "page" => "http://" + domain + page, "siteurl" => "http://" + domain, "papers_data" => papers_data }, :mail_to => deliver_emails)
|
email = Email.new(:mail_subject => paper.sending_title, :mail_lang => args[:locale], :template => "admin/e_paper_criterias/emailer", :template_data => {"paper_id" => paper.id, "page" => "http://" + domain + page, "siteurl" => "http://" + domain, "papers_data" => papers_data }, :mail_to => deliver_emails)
|
||||||
begin
|
begin
|
||||||
|
@ -64,12 +64,12 @@ namespace :epaper do
|
||||||
paper.save
|
paper.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def verify_email(from_addr,check_emails,tls) #true if check_email is ok
|
def epaper_verify_email(from_addr,check_emails,tls) #true if check_email is ok
|
||||||
s = Timeout.timeout(@open_timeout, Net::OpenTimeout) do
|
s = Timeout.timeout(@open_timeout, Net::OpenTimeout) do
|
||||||
TCPSocket.open(@address, @port)
|
TCPSocket.open(@address, @port)
|
||||||
end
|
end
|
||||||
@socket = new_internet_message_io(tls ? tlsconnect(s) : s)
|
@socket = epaper_new_internet_message_io(tls ? epaper_tlsconnect(s) : s)
|
||||||
res = get_response("MAIL FROM:<#{from_addr}>")
|
res = epaper_get_response("MAIL FROM:<#{from_addr}>")
|
||||||
invalid_emails = []
|
invalid_emails = []
|
||||||
check_list = []
|
check_list = []
|
||||||
if check_emails.class == String
|
if check_emails.class == String
|
||||||
|
@ -82,8 +82,8 @@ namespace :epaper do
|
||||||
check_list = check_emails
|
check_list = check_emails
|
||||||
end
|
end
|
||||||
check_list.each do |check_email|
|
check_list.each do |check_email|
|
||||||
res1 = get_response("RCPT TO:<#{check_email}>")
|
res1 = epaper_get_response("RCPT TO:<#{check_email}>")
|
||||||
res2 = get_response("RCPT TO:<#{check_email}>")
|
res2 = epaper_get_response("RCPT TO:<#{check_email}>")
|
||||||
if !(res1.success? && res2.success?)
|
if !(res1.success? && res2.success?)
|
||||||
invalid_emails << check_email
|
invalid_emails << check_email
|
||||||
puts [check_email,res1.message,res2.message]
|
puts [check_email,res1.message,res2.message]
|
||||||
|
@ -92,14 +92,14 @@ namespace :epaper do
|
||||||
s.close
|
s.close
|
||||||
invalid_emails
|
invalid_emails
|
||||||
end
|
end
|
||||||
def get_response(reqline)
|
def epaper_get_response(reqline)
|
||||||
res = critical {
|
res = epaper_critical {
|
||||||
@socket.writeline reqline
|
@socket.writeline reqline
|
||||||
recv_response()
|
epaper_recv_response()
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
def recv_response
|
def epaper_recv_response
|
||||||
buf = ''
|
buf = ''
|
||||||
while true
|
while true
|
||||||
line = @socket.readline
|
line = @socket.readline
|
||||||
|
@ -108,7 +108,7 @@ namespace :epaper do
|
||||||
end
|
end
|
||||||
Net::SMTP::Response.parse(buf)
|
Net::SMTP::Response.parse(buf)
|
||||||
end
|
end
|
||||||
def critical
|
def epaper_critical
|
||||||
return Net::SMTP::Response.parse('200 dummy reply code') if @error_occurred
|
return Net::SMTP::Response.parse('200 dummy reply code') if @error_occurred
|
||||||
begin
|
begin
|
||||||
return yield()
|
return yield()
|
||||||
|
@ -117,12 +117,12 @@ namespace :epaper do
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def ssl_socket(socket, context)
|
def epaper_ssl_socket(socket, context)
|
||||||
OpenSSL::SSL::SSLSocket.new socket, context
|
OpenSSL::SSL::SSLSocket.new socket, context
|
||||||
end
|
end
|
||||||
def tlsconnect(s)
|
def epaper_tlsconnect(s)
|
||||||
verified = false
|
verified = false
|
||||||
s = ssl_socket(s, @ssl_context)
|
s = epaper_ssl_socket(s, @ssl_context)
|
||||||
s.sync_close = true
|
s.sync_close = true
|
||||||
s.connect
|
s.connect
|
||||||
if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
|
if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
|
||||||
|
@ -133,7 +133,7 @@ namespace :epaper do
|
||||||
ensure
|
ensure
|
||||||
s.close unless verified
|
s.close unless verified
|
||||||
end
|
end
|
||||||
def new_internet_message_io(s)
|
def epaper_new_internet_message_io(s)
|
||||||
io = Net::InternetMessageIO.new(s)
|
io = Net::InternetMessageIO.new(s)
|
||||||
io.read_timeout = @read_timeout
|
io.read_timeout = @read_timeout
|
||||||
io.debug_output = @debug_output
|
io.debug_output = @debug_output
|
||||||
|
|
Loading…
Reference in New Issue