【问题标题】:Devise email confirmation not working on Heroku设计电子邮件确认不适用于 Heroku
【发布时间】:2011-06-10 03:33:18
【问题描述】:

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

网址看起来像这样:

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

【问题讨论】:

  • 您的日志中有哪些关于错误的内容?
  • 2011-06-10T03:48:11+00:00 app[web.1]: ArgumentError(发送消息所需的发件人(返回路径、发件人或发件人)):2011- 06-10T03:48:11+00:00 app[web.1]: app/models/user.rb:52:in `confirm!'
  • 它指向这条线UserMailer.welcome_message(self).deliver
  • 你能告诉我们你的邮件类吗?另外,您使用的是 Rails 3 吗?
  • 发布了我的邮件类。是的,Rails 3

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


【解决方案1】:

您缺少“发件人:”值,这是 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-22
    • 1970-01-01
    • 2013-12-09
    • 2017-09-18
    • 1970-01-01
    • 1970-01-01
    • 2012-03-10
    • 2019-08-04
    相关资源
    最近更新 更多