Reputation: 11206
I'm trying to set up a password reset mailer following this railscasts http://railscasts.com/episodes/274-remember-me-reset-password?view=asciicast.
I am able to get my mailer to send emails after following the heroku blog to set up my environment. Please note I'm using namecheap for my domain and gmail/google apps to handle my emails. http://blog.heroku.com/archives/2009/11/9/tech_sending_email_with_gmail/
The problem I'm having though is that the emails I'm receiving is replacing my email where the domain name should be. See below:
To reset your password, click the URL below.
http://[email protected]/password_resets/qVwzCsKHZA-VS6GyDTTyQw/edit
I want it to be:
http://www.mydomain.com/password_resets/qVwzCsKHZA-VS6GyDTTyQw/edit
How do I get the mailer to show the domain name instead of the webmaster email?
I've already checked my code numerous time and I think it's simply a matter of some type of forwarding issue. Let me know if you want me to post any relevant code up.
This is in my production.rb:
config.action_mailer.default_url_options = { :host => "[email protected]" }
password_resets_controller.rb
def create
user = User.find_by_email(params[:email])
user.send_password_reset if user
redirect_to login_path, :notice => "Email sent with password reset"
end
user.rb
def send_password_reset
generate_token(:password_reset_token)
self.password_reset_sent_at = Time.zone.now
save!
UserMailer.password_reset(self).deliver
end
user_mailer.rb
class UserMailer < ActionMailer::Base
default :from => "[email protected]"
def password_reset(user)
@user = user
mail :to => user.email, :subject => "Password Reset"
end
end
password_reset.text.erb
To reset your password, click the URL below.
<%= edit_password_reset_url(@user.password_reset_token) %>
Thanks.
Upvotes: 1
Views: 633
Reputation: 124
Just change your host to whatever your domain name is and it should work: :host => "mydomain.com"
Upvotes: 1