我更改了gmail密码后,当用户尝试发送邮件时,heroku会出现错误

时间:2016-04-16 14:51:43

标签: ruby-on-rails ruby email heroku smtp

在最近更改密码后,我的应用不允许用户发送定向到我的Gmail的邮件。或许,我的Gmail可能不接受来自我的应用程序的消息?我的heroku日志报告了以下错误:

IntPtr tokenObserveButtonEnabled = (IntPtr) 1; UIButton button; public override void ViewDidLoad () { base.ViewDidLoad (); // Perform any additional setup after loading the view, typically from a nib. var textf = new UITextField (new CGRect (150, 150, 50, 50)); button = new UIButton (new CGRect (50, 50, 50, 50)); button.SetTitle ("TEST", UIControlState.Normal); button.SetTitleColor(UIColor.Black, UIControlState.Normal); button.SetTitleColor (UIColor.Gray, UIControlState.Disabled); button.Layer.BorderWidth = 1; button.Layer.CornerRadius = 5; button.AddObserver (this, (NSString)"enabled", NSKeyValueObservingOptions.Old | NSKeyValueObservingOptions.New, tokenObserveButtonEnabled); Add (button); Add (textf); textf.AllEditingEvents += (object sender, EventArgs e) => { var tf = sender as UITextField; button.Enabled = tf.HasText; }; } public override void ObserveValue (NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr ctx) { if (ctx == tokenObserveButtonEnabled) { button.Layer.BorderColor = button.Enabled ? UIColor.Black.CGColor : UIColor.Gray.CGColor ; } }

我试过了:

•更新我使用费加罗生成的Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted.)文件中的密码。

application.yml

•确保gmail中heroku restart设置为Allow less secure apps:

•启用/停用ON

我可以通过heroku控制台看到消息正在生产表中保存。同样,问题是从未在Gmail中收到消息。这个问题仅在生产中,而不是在开发中。

配置/ application.rb中

enable_starttls_auto: true

为setup_mail.rb

require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(*Rails.groups)
module ChrisPelnarDotCom
  class Application < Rails::Application
    config.active_record.raise_in_transactional_callbacks = true
    config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = {
      address:              'smtp.gmail.com',
      port:                 587,
      domain:               'gmail.com',
      user_name:            ENV["gmail_username"],
      password:             ENV["gmail_password"],
      authentication:       'plain',
      enable_starttls_auto: true  }
    end
end

配置/ application.yml

ActionMailer::Base.smtp_settings = {
  :address => "smtp.gmail.com",
  :port  => 587,
  :domain  => 'www.yourdomain.com',
  :user_name => ENV["gmail_username"],
  :password => ENV["gmail_password"],
  :authentication => 'plain',
  :enable_starttls_auto => true
}

ActionMailer::Base.default_url_options[:host] = ENV["gmail_username"]

1 个答案:

答案 0 :(得分:2)

您还需要使用gmail_password更新生产中的heroku config:set gmail_password=YOURNEWPASSWORD --app YOURAPPNAME环境变量中的密码。 application.yml只应该用于开发。