2017-03-17 47 views
0

我曾經使用過寶石,在那裏我安排超過500封郵件在特定時間執行,但它不會。但如果我發送15或20封電子郵件, 。我每次都在輸出文件中獲得以下內容。無法發送大宗電子郵件時使用任何寶石在軌道上

rake aborted! 
 
Net::SMTPServerBusy: 452 4.5.3 Error: too many recipients 
 
/home/indiba3/.rvm/gems/ruby-2.1.8/gems/mail-2.6.4/lib/mail/network/delivery_methods/smtp.rb:114:in `block in deliver!' 
 
/home/indiba3/.rvm/gems/ruby-2.1.8/gems/mail-2.6.4/lib/mail/network/delivery_methods/smtp.rb:113:in `deliver!' 
 
/home/indiba3/.rvm/gems/ruby-2.1.8/gems/mail-2.6.4/lib/mail/message.rb:253:in `deliver!' 
 
/home/indiba3/.rvm/gems/ruby-2.1.8/gems/actionmailer-4.2.4/lib/action_mailer/message_delivery.rb:77:in `deliver_now!' 
 
/home/indiba3/.rvm/gems/ruby-2.1.8/gems/actionmailer-4.2.4/lib/action_mailer/message_delivery.rb:95:in `deliver!' 
 
/home/indiba3/hrms/lib/tasks/email_tasks.rake:25:in `block (2 levels) in <top (required)>' 
 
/home/indiba3/.rvm/gems/ruby-2.1.8/gems/rake-12.0.0/exe/rake:27:in `<top (required)>' 
 
/home/indiba3/.rvm/gems/ruby-2.1.8/bin/ruby_executable_hooks:15:in `eval' 
 
/home/indiba3/.rvm/gems/ruby-2.1.8/bin/ruby_executable_hooks:15:in `<main>' 
 
Tasks: TOP => task_namespace:birthday_invitation_mail 
 
(See full trace by running task with --trace)

那麼請問有什麼可以解決售後服務這個錯誤,讓電子郵件被髮送到500人,如果任何電子郵件是錯了,我可能會在另一個日誌文件輸出..... ...所以請幫助........... ??

回答

0

批量提取用戶,然後嘗試發送郵件。

郵包
def birthday_email 
    date = Date.today 
    Employee.where("status = ? AND strftime('%d/%m', date_of_birth) = ?", "Active" , date.strftime('%d/%m')).where("age > 21").find_in_batches do |group| 
     sleep(5) 
     group.each { |emp| mail(to: emp.email, subject: 'Birthday Wishes') } 
    end 

end 

EmployeeMailer.birthday_email.deliver! 
+0

註釋不是延長討論;這個談話已經[轉移到聊天](http://chat.stackoverflow.com/rooms/138535/discussion-on-answer-by-puneet18-unable-to-send-bulk-email-using-whenever-gems-一世)。 –

相關問題