Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionMailer not sending mail in development Rails 4

Why is this mailer not sending any mail? (Or any ideas for debugging?)

In my_app/config/environments/development.rb I have this code:

  config.action_mailer.delivery_method = :smtp   config.action_mailer.smtp_settings = {     address:              'smtp.gmail.com',     port:                 587,     domain:               'my_app.com',     user_name:            ENV['GMAIL_USERNAME'],     password:             ENV['GMAIL_PASSWORD'],     authentication:       'plain',     enable_starttls_auto: true  } 

Then on my local computer in ~/.bash_profile I have this code:

export GMAIL_USERNAME='blah@my_app.com' export GMAIL_PASSWORD='***' 

When I run $ env in my terminal, I see that both environment variables are correctly set.

I have also restarted my rails server.

like image 295
Don P Avatar asked Dec 25 '13 06:12

Don P


People also ask

How do I use SMTP in Ruby on Rails?

Go to the config folder of your emails project and open environment. rb file and add the following line at the bottom of this file. It tells ActionMailer that you want to use the SMTP server. You can also set it to be :sendmail if you are using a Unix-based operating system such as Mac OS X or Linux.

What is action_ mailer in Rails?

Action Mailer allows you to send emails from your application using a mailer model and views. So, in Rails, emails are used by creating mailers that inherit from ActionMailer::Base and live in app/mailers. Those mailers have associated views that appear alongside controller views in app/views.

How does ActionMailer work?

Action Mailer allows you to send emails from your application using mailer classes and views. Mailers work very similarly to controllers. They inherit from ActionMailer::Base and live in app/mailers , and they have associated views that appear in app/views .


1 Answers

You should add

config.action_mailer.perform_deliveries = true 

as by default this is on false, preventing mails to be sent from your development environment...

like image 55
Danny Avatar answered Oct 13 '22 16:10

Danny