Actionmailer not working when I change gmail password

谁说我不能喝 提交于 2019-11-26 22:02:38

问题


I have a Rails app that uses Gmail to send Actionmailer emails. It has been working great for months, but now that I changed my Gmail password it has stopped working and I get an error:

Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted.

I've adjusted the new password in my production.rb and development.rb files:

config.action_mailer.smtp_settings = {
address:              'smtp.gmail.com',
port:                 587,
#domain:               'thetens.us',
user_name:            'myaddress@gmail.com',
password:             'mypassword',
authentication:       'plain',
enable_starttls_auto: true  }

I'm sure the password is correct. Is there some way to force it to update wherever it's not being updated?


回答1:


Create a file named as setup_mail.rb in config/initializers/ folder so that it looks like

config/initializers/setup_mail.rb

and put the below code in that file:-

ActionMailer::Base.smtp_settings = {
  :address => "smtp.gmail.com",
  :port  => 587,
  :domain  => 'www.yourdomain.com',
  :user_name => "myaddress@gmail.com",
  :password => "mypassword",
  :authentication => 'plain',
  :enable_starttls_auto => true
}

ActionMailer::Base.default_url_options[:host] = "www.yourdomain.com"


来源:https://stackoverflow.com/questions/23300150/actionmailer-not-working-when-i-change-gmail-password

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!