【问题标题】:Rails: devise mails "sent" according to log but not receiving any in my gmail inboxRails:根据日志设计邮件“已发送”,但在我的 gmail 收件箱中未收到任何邮件
【发布时间】:2016-06-02 14:55:40
【问题描述】:

我已检查该电子邮件是否已被过滤为垃圾邮件,但垃圾邮件文件夹不包含它。

config/environments/production.rb

config.action_mailer.default_url_options = { :host => 'example.com' }
# ActionMailer Config
# Setup for production - deliveries, no errors raised
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
config.action_mailer.default :charset => "utf-8"

config/environments/production.rb

config.action_mailer.smtp_settings = {
  address: "smtp.gmail.com",
  port: 587,
  domain: "example.com",
  authentication: "plain",
  enable_starttls_auto: true,
  user_name: ENV["GMAIL_USERNAME"],
  password: ENV["GMAIL_PASSWORD"]
}

config/initializers/devise.rb

config.mailer_sender = 'example@gmail.com'

Heroku 日志:

2016-06-03T10:42:41.963581+00:00 app[web.1]: Sent mail to ****@gmail.com (1222.9ms)

我也尝试过开发,但得到了相同的结果。不知何故,它正在发送,但从未到达。

谁能帮我解决这个问题?

【问题讨论】:

  • 您的邮件是否指定了接收电子邮件的地址?
  • @stephenmurdoch 是的:config.mailer_sender = 'example@gmail.com'。我会将其添加到我的问题中以进行澄清。
  • 你可以在本地主机上的命令行运行envprintenv 吗?我想知道您的环境变量是否在某处被覆盖。
  • 不知何故,邮件程序今天正在为生产工作。我没有更改代码,但现在我收到了实际的确认电子邮件。

标签: ruby-on-rails email devise


【解决方案1】:

在您配置的 Gmail 帐户中:

  1. 转到帐户设置

  2. 转到登录和安全,然后是连接的应用和网站

  3. 最后在 允许不太安全的应用程序 ...检查它。

我的发送邮件的开发环境设置

开发.rb =>

 config.action_mailer.delivery_method = :smtp

=> 在初始化程序中 => 创建文件为 mail_setup.rb,粘贴此配置

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  # :domain               => "http://localhost:8082.com",
  :user_name            => "mukesh.sharma@skilrock.com",
  :password             => "**************",
  :authentication       => "plain",
  :enable_starttls_auto => true
}

【讨论】:

  • 我检查了我用来发送电子邮件的 gmail 帐户的配置。允许不太安全的应用程序状态为“开启”。但是当我再次尝试注册时,gmail帐户并没有向用户的gmail发送确认邮件。
  • 创建文件 mail_setup.rb 后,尝试注册后出现错误:到达文件结尾。所以我使用了 spring stop 并再次尝试。现在不同的错误:535-5.7.8 用户名和密码不被接受。了解更多信息。我很困惑:(。
  • 我还看到我的 gmail 帐户说:检测到异常活动。这很奇怪,因为允许不太安全的应用程序的状态是开启
  • 这不是什么大问题...n 始终在 gmail 上保留一个测试帐户,以便在应用程序上进行测试:)
  • 在mail_setup.rb中检查你的gamil用户名和密码一次
猜你喜欢
  • 1970-01-01
  • 2016-12-09
  • 2014-10-08
  • 1970-01-01
  • 2015-10-15
  • 1970-01-01
  • 1970-01-01
  • 2015-02-06
  • 2011-09-14
相关资源
最近更新 更多