Background
Trying to resolve an issue with Gmail setup for ActionMailer in Rails 3.2.x running on a Ubuntu instance at Amazon EC2. The application is running with Nginx + Passenger.
The setup is as follows
File: config/environments/production.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:authentication => :plain,
:user_name => "<username>@gmail.com",
:password => "<secret-word>",
:enable_starttls_auto => true
}
Email is working on Google account as verified by web login and sending a test message.
A controller initiates the send via a method as:
email_list_controller.rb
def email_test_send
@email = params[:email]
@message = Message.find(params[:id])
@member = Member.find_by_last_name("Bloggs")
MemberMailer.delay.all_member_email(@member.email, @message)
redirect_to messages_path, :notice => "Test Email has been sent."
end
with the MemberMailer class defined as:
class MemberMailer < ActionMailer::Base
default from: "[email protected]"
default cc: "[email protected], [email protected]"
default content_type: "text/html"
# send a message to member
def all_member_email(email, message)
@message = message
mail(:to => email, :subject => message.subject)
end
end
The system is using the Delayed_Job Gem for background processing and the sending has been tested both with and without the background job processing.;
Outcome
The problem is that no message is sent and the following occurs
Output in production.log (with log_level set at DEBUG
Processing by EmailListController#email_test_send as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"D5ZCb+Ha63WbPmd47/1/P3rpFJFiSbnrYya+YaSmBic=", "email"=>"[email protected]", "commit"=>"Submit", "id"=>"1", "method"=>"post"}
No message is delivered
Google account sent folder doesn't show any outbound message details.
Verified that server on EC2 can connect to Google SMTP server via telnet 587
Investigated other StackOverflow questions such as Setting up a Gmail Account to work with ActionMailer in Rails 3
No faults located in the database in the delayed_jobs table.
So stuck for any other areas to look at ? I've tried restarting the server to ensure clean loading of the config files etc, but no luck.