设计电子邮件确认在 Heroku 上不起作用

发布于 2024-11-14 16:25:50 字数 1011 浏览 2 评论 0原文

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

该网址看起来像这样:

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

When I click on the link in my confirmation email that devise sends, it seems to go to a path that is not recognized by my application.

The url looks something like this:

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

which looks correct, but it seems to go to my 500.html file.

It has something to do with this code in my user model that overrides Devise's confirm! method:

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

According to my logs, this is the error:

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!'

which points to this line: UserMailer.welcome_message(self).deliver

Here's my user mailer class:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

向地狱狂奔 2024-11-21 16:25:50

您缺少“from:”值,这是 SMTP 处理所必需的:

class UserMailer < ActionMailer::Base
  # Option 1
  #default_from "[email protected]"

  def welcome_message(user)
    @user = user
    mail(
      # Option 2
      :from => "[email protected]",
      :to => user.email, 
      :subject => "Welcome to DreamStill"
    )
  end
end

You are missing the "from:" value, it's a must for SMTP handling:

class UserMailer < ActionMailer::Base
  # Option 1
  #default_from "[email protected]"

  def welcome_message(user)
    @user = user
    mail(
      # Option 2
      :from => "[email protected]",
      :to => user.email, 
      :subject => "Welcome to DreamStill"
    )
  end
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文