切换到自定义域后,Heroku Mailer突然无法正常工作

时间:2012-01-03 23:44:09

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

我有一个实时应用程序(livebytransit.com),我最近切换到自定义域,而不是简单地使用隐藏转发。域名是Godaddy。一切都很好看,除了我的邮件不再有效!

以下是heroku日志的错误:

2012-01-03T22:36:17+00:00 app[web.1]: Rendered showing_mailer/showing_request.html.erb (0.5ms)
2012-01-03T22:36:17+00:00 app[web.1]: 
2012-01-03T22:36:17+00:00 app[web.1]: Sent mail to info@livebytransit.com (213ms)
2012-01-03T22:36:17+00:00 app[web.1]: Completed 500 Internal Server Error in 242ms
2012-01-03T22:36:17+00:00 app[web.1]: EOFError (end of file reached):
2012-01-03T22:36:17+00:00 app[web.1]:   app/controllers/showings_controller.rb:12:in `create'

从我的production.rb配置文件:

config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp

初​​始化器:

ActionMailer::Base.smtp_settings = {
  :address  => "smtpout.secureserver.net",
  :port  => 25,
  :user_name  => "username",
  :password  => "password",
  :authentication  => :login
}

邮件程序:

class InviteeMailer < ActionMailer::Base
  default from: "admin@livebytransit.com"

  def send_invite(invitee)
        @invitee = invitee
        mail(:to => @invitee.email, :subject => "You have been Invited")
  end

end

最后是控制器:

def create
    @invitee = Invitee.new
    @invitee.email = (params[:email])
    @invitee.user_id = session[:user_id]
    @invitee.save
    InviteeMailer.send_invite(@invitee).deliver
    redirect_to user_url(session[:user_id]), :notice => "Invitation Sent, thank you!"
  end

被邀请者正在保存,但由于EOFError,邮件无法发送。这对我来说闻起来像配置问题,但我似乎无法弄明白,任何想法都会被赞赏!再次,邮件工作正常,直到我切换到自定义域。

1 个答案:

答案 0 :(得分:0)

heroku帮助台建议我添加sendgrid。所以我添加了sendgrid,然后错误改为:

Net::SMTPFatalError (553 Sorry, your envelope sender is in my badmailfrom list

此错误促使我为默认的“发件人”地址设置了电子邮件地址,如邮件程序所示。

问题解决了。

当应用程序部署到默认的myapp.herokuapp.com时,我不确定为什么会发送电子邮件。切换到我的自定义域后,问题才会出现。