ssandoy
ssandoy

Reputation: 79

ActionMailer not sending mail in development Rails 5

I am having some problem with sending email in my web-application. When I am running development the email is not sent even though it is showing as sent in the Console.

This is my settings in config/environments/development.rb

# Email
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: '587',
enable_starttls_auto: true,
user_name: ENV["gmail_username"],
password:  ENV["gmail_password"],
authentication: :plain,
domain: 'gmail.com'
}

In my controller I am sending mail using this call:

 JobMailer.send_accept_job_mail(@app_user, @job.id).deliver

The mail is showing as "sent" in the Console, but it is not sent to the specified mail.

Upvotes: 3

Views: 5237

Answers (1)

Máté
Máté

Reputation: 2345

You need to use deliver! to send out the mail immediately.

Just update the code to

JobMailer.send_accept_job_mail(@app_user, @job.id).deliver!

-- edited to use deliver! method, per comments.

Upvotes: 6

Related Questions