2013-05-07 116 views
2

我在Google Apps上托管了自己的域名。 我的电子邮件发送在我的笔记本电脑上以开发模式工作。Heroku上的Rails应用程序发送电子邮件错误

在Heroku(雪松堆栈)上的生产中出现此错误: Net :: SMTPAuthenticationError(535-5.7.8未接受用户名和密码了解更多信息,请参阅app/controllers/applicants_controller.rb:16: “):

这里是我的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: "[email protected]", 
    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 

这里为t他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 [email protected] (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帐户。如果您尝试登录,我不会在任何地方看到它询问您,因此我可以确认。

还有其他想法吗?

回答

5

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

相关问题