【问题标题】:Rails App on Heroku Sending Email ErrorHeroku 上的 Rails 应用程序发送电子邮件错误
【发布时间】:2013-05-07 15:00:23
【问题描述】:

我在 Google Apps 上托管了自己的域名。 我的电子邮件发送在我的笔记本电脑上以开发模式工作。

在 Heroku(雪松堆栈)上的生产中,我收到此错误: Net::SMTPAuthenticationError(535-5.7.8 用户名和密码不被接受。在 app/controllers/applicants_controller.rb:16:in `create' 了解更多信息):

这是我的 production.rb 文件:

config.action_mailer.default_url_options = { :host => 'mydomain.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 = true
   config.action_mailer.default :charset => "utf-8"

   config.action_mailer.smtp_settings = {
     address: "smtp.gmail.com",
     port: 587,
     domain: "mydomain.com",
     authentication: "plain",
     enable_starttls_auto: true,
     user_name: "info@mydomain.com",
     password: "mypassword"
   }

这是 contacts_controller 中的创建操作:

 def create  
      @contact = Contact.new(params[:contact])  

      respond_to do |format|  
        if @contact.save  
          ContactMailer.new_contact_notice(@contact).deliver 
          format.html { redirect_to(:root, :notice => 'Thanks, Your information was successfully sent.') }  

        else  
          format.html { render :action => "show" }  

        end  
      end  
    end

这里是 Heroku 日志中指出错误的完整部分:

2013-05-07T05:01:54.773576+00:00 app[web.1]: Started POST "/applicants" for 108.208.197.181 at 2013-05-07 05:01:54 +0000
2013-05-07T05:01:55.132454+00:00 app[web.1]:   app/controllers/applicants_controller.rb:18:in `block in create'
2013-05-07T05:01:55.130426+00:00 app[web.1]: 
2013-05-07T05:01:55.132454+00:00 app[web.1]: 
2013-05-07T05:01:55.130426+00:00 app[web.1]: Sent mail to name@gmail.com (185ms)
2013-05-07T05:01:55.132454+00:00 app[web.1]: 
2013-05-07T05:01:55.132454+00:00 app[web.1]: Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted. Learn more at
2013-05-07T05:01:55.132454+00:00 app[web.1]:   app/controllers/applicants_controller.rb:16:in `create'
2013-05-07T05:01:55.132454+00:00 app[web.1]: ):
2013-05-07T05:01:55.132454+00:00 app[web.1]: 

我已经尝试了一些有关此错误的信息,例如先登录到 gmail 帐户。我在设置中没有看到它询问您是否尝试登录的任何地方,因此我可以确认。

还有其他想法吗?

【问题讨论】:

    标签: ruby-on-rails-3 heroku gmail


    【解决方案1】:

    我花了三天时间,但我找到了答案。除了 config/initializers 中的 setup_mail.rb 之外,我已经检查并重新检查了所有地方的邮件设置。就是这样。即使我的 production.rb、application.yml 和 mailer 文件中的所有邮件设置都是正确的。我只有用户名“name”而不是完整的电子邮件地址“name@domain.com”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-06
      • 2017-07-15
      • 1970-01-01
      • 1970-01-01
      • 2014-10-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多