From ecdbe51c92c0e7d0142cdfa53d2ce08594946078 Mon Sep 17 00:00:00 2001 From: Bohung Date: Mon, 1 Nov 2021 11:40:14 +0800 Subject: [PATCH] Fix send mail bug. --- lib/tasks/e_paper_tasks.rake | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/tasks/e_paper_tasks.rake b/lib/tasks/e_paper_tasks.rake index 868d33a..c9f9388 100644 --- a/lib/tasks/e_paper_tasks.rake +++ b/lib/tasks/e_paper_tasks.rake @@ -30,7 +30,7 @@ namespace :epaper do site = Site.first @address = site['site_settings']['address'] @port = (site['site_settings']['port'].to_i rescue 587) - @open_timeout = 30 + @open_timeout = 10 @read_timeout = 60 @debug_output = nil tls = (site['site_settings']['enable_starttls_auto'] == "1") @@ -83,11 +83,16 @@ namespace :epaper do check_list = check_emails end check_list.each do |check_email| - res1 = epaper_get_response("RCPT TO:<#{check_email}>") - res2 = epaper_get_response("RCPT TO:<#{check_email}>") - if !(res1.success? && res2.success?) + begin + res1 = epaper_get_response("RCPT TO:<#{check_email}>") + res2 = epaper_get_response("RCPT TO:<#{check_email}>") + if !(res1.success? && res2.success?) + invalid_emails << check_email + puts [check_email,res1.message,res2.message] + end + rescue => e + puts e.to_s invalid_emails << check_email - puts [check_email,res1.message,res2.message] end end s.close