I upgraded the Rails application to 5.0.6 from 4.2.5. Now emails are not sent using the Mail gem. I don't seem to get any errors. I updated the zip stone to the latest version with no luck. I'm not sure what else to try.
I run:
Rails 5.0.6
Ruby 2.3.0
Mail 2.7.0
Controllers / send_email.rb
class SendEmail < ApplicationController def initialize(to_address, from_address, email_pass, subject, body) begin options = { :address => 'abc.prod.1234.secureserver.net', :port => '465', :domain => 'mydomain.com', :user_name => from_address, :password => email_pass, :authentication => :login, :ssl => true, :openssl_verify_mode => 'none' } Mail.defaults do delivery_method :smtp, options end Mail.deliver do to to_address from from_address subject subject body body end puts("\nSent message. From: #{from_address} To: #{to_address} \nMessage body: \n#{body}") return true rescue Exception => e puts e.to_s return false end end end
Update:
I tried sending an email using Action Mailer. He says that he goes to the console, but he never gets delivered. I use the same settings for Action Mailer, since I use a mail stone.
configurations / environment / development.rb
config.action_mailer.smtp_settings = { :address => 'abc.prod.1234.secureserver.net', :port => '465', :domain => 'mydomain.com', :user_name => ENV['default_username'], :password => ENV['default_password'], :authentication => :login, :ssl => true, :openssl_verify_mode => 'none' }
I run this from the console:
EmailMailer.sample_email(UserEmail.first)
Console output:
Rendering email_mailer/sample_email.html.erb within layouts/mailer Rendered email_mailer/sample_email.html.erb within layouts/mailer (0.1ms) Rendering email_mailer/sample_email.text.erb within layouts/mailer Rendered email_mailer/sample_email.text.erb within layouts/mailer (0.0ms) EmailMailer
Decision:
I have a code that sends an email when there is an unknown error that I need to look at. When I update Rails, this code got into a loop that quickly sent a bunch of emails. This made my server provider mark my email account as a spam account. I donβt know why there were no errors in my source code, but when I started EmailMailer.sample_email(UserEmail.first).deliver_now , it gave me an error message that helped me track it.