Rails 4 Net :: SMTPSyntaxError: 501 Syntax Error for Mass Mail

I have a cronjob that sends newsletters daily. For some reason, an error has occurred.

I checked the stack trace and got this

Net::SMTPSyntaxError: 501 Syntax error from /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/smtp.rb:957:in `check_response' from /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/smtp.rb:926:in `getok' from /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/smtp.rb:869:in `rcptto' from /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/smtp.rb:850:in `block in rcptto_list' from /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/smtp.rb:848:in `each' from /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/smtp.rb:848:in `rcptto_list' from /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/smtp.rb:663:in `send_message' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/mail-2.6.3/lib/mail/network/delivery_methods/smtp.rb:113:in `block in deliver!' from /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/smtp.rb:521:in `start' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/mail-2.6.3/lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/mail-2.6.3/lib/mail/message.rb:2141:in `do_delivery' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/mail-2.6.3/lib/mail/message.rb:236:in `block in deliver' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/actionmailer-4.1.8/lib/action_mailer/base.rb:527:in `block in deliver_mail' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/notifications.rb:159:in `block in instrument' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/notifications.rb:159:in `instrument' ... 3 levels... from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/commands/console.rb:90:in `start' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/commands/console.rb:9:in `start' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:69:in `console' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:40:in `run_command!' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/commands.rb:17:in `<top (required)>' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/app_rails_loader.rb:43:in `require' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/app_rails_loader.rb:43:in `block in exec_app_rails' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/app_rails_loader.rb:32:in `loop' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/app_rails_loader.rb:32:in `exec_app_rails' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/cli.rb:5:in `<top (required)>' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/railties-4.1.8/bin/rails:9:in `require' from /var/www/lsd-core/shared/bundle/ruby/2.1.0/gems/railties-4.1.8/bin/rails:9:in `<top (required)>' from /usr/local/rvm/gems/ruby-2.1.5/bin/rails:23:in `load' from /usr/local/rvm/gems/ruby-2.1.5/bin/rails:23:in `<main>' from /usr/local/rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `eval' 

Initially, I thought it was a bad email format in the recipient list, but after weeding a few, I still get an error message after manually starting the mailing list.

I tried iterating through each recipient and sending them an email, and it worked! Even for bad letters.

Is there a maximum number of recipients when sending using ActionMailer?

+6
source share
1 answer

As far as I know, ActionMailer does not impose restrictions on the number of recipients. The error you get comes from your SMTP server, so most likely where the error is.

An error was sent when sending one of several RCPT TO: to net/smtp.rb:869 . The most likely explanation will be the wrong address, but you declare that each address worked when sending independently. You can try sending a letter to a large number of your own addresses and see if the same error appears.

Regardless of whether you find a reason, you can consider sending each newsletter separately. The added overhead of sending one mail per recipient is likely to be worth it if it avoids such disruptions. Good luck

+1
source

Source: https://habr.com/ru/post/989710/


All Articles