设计电子邮件确认无法在Heroku上运行

时间:2011-06-10 03:33:18

标签: ruby-on-rails ruby-on-rails-3 devise actionmailer sendgrid

当我点击设计发送的确认电子邮件中的链接时,它似乎转到我的应用程序无法识别的路径。

网址看起来像这样:

http://glowing-flower-855.heroku.com/users/confirmation?confirmation_token=lIUuOINyxfTW3TBPPI

看起来不错,但似乎是我的500.html文件。

它与我的用户模型中的代码有关,它覆盖了Devise的confirm!方法:

def confirm!
  UserMailer.welcome_message(self).deliver
  super
end 

根据我的日志,这是错误:

2011-06-10T03:48:11+00:00 app[web.1]: ArgumentError (A sender (Return-Path, Sender or From) required to send a message): 
2011-06-10T03:48:11+00:00 app[web.1]: app/models/user.rb:52:in `confirm!'

指向此行:UserMailer.welcome_message(self).deliver

这是我的用户邮件程序类:

class UserMailer < ActionMailer::Base
  def welcome_message(user)
    @user = user
    mail(:to => user.email, :subject => "Welcome to DreamStill")
  end
end

1 个答案:

答案 0 :(得分:7)

您缺少“from:”值,这是SMTP处理的必备条件:

class UserMailer < ActionMailer::Base
  # Option 1
  #default_from "bob@dylan.com"

  def welcome_message(user)
    @user = user
    mail(
      # Option 2
      :from => "paul@mccarthy.com",
      :to => user.email, 
      :subject => "Welcome to DreamStill"
    )
  end
end