问题描述
我有一个使用Gmail发送Actionmailer电子邮件的Rails应用程序。它已经工作了好几个月了,但现在我改变了我的Gmail密码,它已停止工作,我收到一个错误:
Net :: SMTPAuthenticationError(535-5.7.8用户名和密码不被接受)
我调整了新的密码在我的production.rb和development.rb文件中:
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
端口:587,
#domain:'thetens.us',
user_name:'[email protected]',
密码:' mypassword',
authentication:'plain',
enable_starttls_auto:true}
我确信密码是正确的。有什么方法可以强制更新,无论它在哪里不更新?
创建在 config / initializers / 中为一个名为 setup_mail.rb 的文件因此它看起来像
config / initializers / setup_mail.rb
并将下面的代码放在该文件中: -
pre $ ActionMailer :: Base.smtp_settings = {
:address => smtp.gmail.com,
:port => 587,
:domain => 'www.yourdomain.com',
:user_name => [email protected],
:password => mypassword,
:authentication => 'plain',
:enable_starttls_auto => true
}
ActionMailer :: Base.default_url_options [:host] =www.yourdomain.com
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: '[email protected]',
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?
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 => "[email protected]",
:password => "mypassword",
:authentication => 'plain',
:enable_starttls_auto => true
}
ActionMailer::Base.default_url_options[:host] = "www.yourdomain.com"
这篇关于当我更改Gmail密码时,Actionmailer不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!