Can't send email using Gmail on Heroku
This is an active app I have had forever where the mail still works. Try changing the auth type to a symbol rather than a string. So :plain instead of 'plain'.
config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => 'smtp.gmail.com',
:port => 587,
:authentication => :plain,
:domain => 'blarg.com',
:user_name => 'info@blarge.com',
:password => 'password'
}
config.action_mailer.default_url_options = { :host => 'blarg.heroku.com' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
Nodemailer Gmail SMTP not working on heroku
You can try using google apis oauth 2.0 and setting yourself as a tester and sending mail on your behalf docs
Laravel password reset email not sending using gmail on Heroku
Don't use Gmail in production¹.
Gmail isn't designed to act as an SMTP gateway for your application. Instead, use one of the many mail addons that Heroku recommends. Mailgun and SendGrid are both very popular options, but there are lots of others.
These tools are designed to send mail for applications. They'll be a lot less likely to reject your mail and, when configured properly, make it a lot less likely for your mail to get caught in spam filters. Most of them have walkthroughs for setting things up, and I encourage you to follow them. Make sure not to skip the SPF and DKIM anti-spam features.
I have read here that I have to hard-code the values inside
app/mail.php
instead of referencing the.env
file because Heroku wouldn't recognize/understand this reference'password' => env('MAIL_PASSWORD')
This is incorrect.
You say that you've set config variables on Heroku, and that populates the environment. The .env
file is just a convenient local workaround for doing the same thing. Whichever mail addon you choose will automatically set one or more environment variables for you, and you should use those in your code.
¹You probably shouldn't be using it in development, either, but it's less of a problem there. I urge you to use something like Mailtrap (cloud) or Mailcatcher (local) instead.
Email for user confirmation not sending in production. Rails, Heroku, Gmail
Check this youtube video youtube.com/watch?v=INPqBOerfTw&t=63s
I prefer to use mandrill app instead of gmail
https://mandrillapp.com/login/?referrer=%2F
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => 587,
:domain => 'www.xyz.com',
:user_name => 'xyz',
:password => 'xxx',
:authentication => :plain,
:enable_starttls_auto => true
}
Related Topics
Best Practices For Reusing Code Between Controllers in Ruby on Rails
Serving Static Files With Sinatra
Why Are My Basic Heroku Apps Taking Two Seconds to Load
Unresolved Specs During Gem::Specification.Reset:
Pass a Variable into a Partial, Rails 3
How to Access Method Arguments in Ruby
Dry Ruby Initialization With Hash Argument
Convert Time from One Time Zone to Another in Rails
Installing Nokogiri on Osx 10.10 Yosemite
Why Are All Rails Helpers Available to All Views, All the Time? How to Disable This
Rails4 Unknown Encoding Name - Cp720
Why Do I Get a "Permission Denied" Error While Installing a Gem
How to Use Rvm and Create Globally Available Gems
What Is the Use of Gemfile in Rails
How to Search a Folder and All of Its Subfolders For Files of a Certain Type