Devise email confirmation not working on Heroku
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
You are missing the "from:" value, it's a must for SMTP handling:
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
精彩评论