当我更改 gmail 密码时,Actionmailer 无法正常工作 [英] Actionmailer not working when I change gmail password

查看:34
本文介绍了当我更改 gmail 密码时,Actionmailer 无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 Gmail 发送 Actionmailer 电子邮件的 Rails 应用程序.几个月来它一直运行良好,但现在我更改了我的 Gmail 密码,它已停止运行,并且出现错误:

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.

我在 production.rb 和 development.rb 文件中调整了新密码:

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?

推荐答案

config/initializers/ 文件夹中创建一个名为 setup_mail.rb 的文件,使其看起来像

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"

这篇关于当我更改 gmail 密码时,Actionmailer 无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆