Rails ActionMailer not sending emails in production; no errors
This code works perfectly on development and the email never arrives in
production, even though they have the same configuration.
Config:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'domain.com' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:authentication => :plain,
:user_name => 'my_server@gmail.com',
:password => 'secret',
:enable_starttls_auto => true
}
Sending the email:
logger.warn "before mail call"
logger.warn ActionMailer::Base.smtp_settings
logger.warn(mail(to: "my_email@gmail.com", subject: "Testing", body:
"email body").deliver!)
Server logs:
[2013-08-29 16:41:11.000] [WARN] -- before mail call
[2013-08-29 16:41:11.000] [WARN] -- {:address=>"smtp.gmail.com",
:port=>587, :authentication=>:plain, :user_name=>"my_server@gmail.com",
:password=>"secret", :enable_starttls_auto=>true}
[2013-08-29 16:41:11.000] [WARN] -- Date: Thu, 29 Aug 2013 16:41:11 +0200
From: my_server@gmail.com
To: my_email@gmail.com
Message-ID: <521f5d87537af_7af3da480050052@castillo05.fzi.de.mail>
Subject: Testing
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
email body
In development on my localhost it works perfectly. The email arrives
almost instantly. On production the email never arrives and I get no
error. I have already tried so many combinations of settings (with/without
:enable_starttls_auto, :domain, not setting delivery_method,
perform_deliveries, etc) and nothing has worked so far. I have also tried
sending to other emails with no success.
Any ideas? Many thanks in advance
No comments:
Post a Comment