Question

I've looked all over Google and stackoverflow for an answer, but none of them work. I'm trying to set up smtp emailing for user confirmation after signing up. It works fine in development. Even with MailCatcher on, it bypasses it somehow and sends to the right email from my assigned gmail.

Here's what's in development.rb:

config.action_mailer.default_url_options = { :host => 'localhost:3000'}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {:address => "localhost", :port => 1025}

Here's what's in production.rb:

 config.action_mailer.default_url_options = {:host => 'myapp.herokuapp.com', :protocol => 'http'} #I've also tried it without ":protocol => 'http'"
 config.action_mailer.raise_delivery_errors = true
 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,   # I've also tried :login
     :enable_starttls_auto => true,  # Also tried tls => true
     :user_name => 'myemail@gmail.com',
     :password => 'mypassword'
   } #I've also tried having the attribute :domain => 'myapp.herokuapp.com',

In config/initializers/devise.rb

config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'  #It still sends from myemail@gmail.com even with this line uncommented.

I don't know how to paste out my entire 7 pages (in word document) worth of heroku logs in code block, so I've pasted them in a google doc.

google doc of heroku logs (I believe I highlighted the part where it started to go wrong on page 1-2):

https://docs.google.com/document/d/1G-cCX7T1sPL5XtjyjHRaWmzfaBbWkuTR2edsDmDm1Pc/edit?usp=sharing

I'm not sure where it's finding the correct email to send from in development. I'm still a novice at this.

edit: I just found out that users that were registered before adding confirmation are not able to log in as well, so it might be a users problem with heroku. But everything still works fine in development.

Help is greatly appreciated, thanks!

Was it helpful?

Solution

You might miss this config.action_mailer.perform_deliveries = true

OTHER TIPS

Please check if your gmail asked for captcha for sending the mail or not. and to debug the error please make config.action_mailer.raise_delivery_errors = true on your production.rb .Please check the similar question Net::SMTPAuthenticationError when sending email from Rails app (on staging environment)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top