1

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

网址看起来像这样:

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
4

1 回答 1

7

您缺少“发件人:”值,这是 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
于 2011-06-10T04:37:50.873 回答