Created
October 3, 2014 19:35
-
-
Save cktricky/54ab05b3b67828d7dcc0 to your computer and use it in GitHub Desktop.
Forgot Password - MyMailer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyMailer < Devise::Mailer | |
def confirmation_instructions(record, token, opts={}) | |
# code to be added here later | |
end | |
def reset_password_instructions(record, token, opts={}) | |
options = { | |
:subject => "Password Reset", | |
:email => record.email, | |
:global_merge_vars => [ | |
{ | |
name: "password_reset_link", | |
content: "http://www.example.com/users/password/edit?reset_password_token=#{token}" | |
} | |
], | |
:template => "Forgot Password" | |
} | |
mandrill_send options | |
end | |
def unlock_instructions(record, token, opts={}) | |
# code to be added here later | |
end | |
def mandrill_send(opts={}) | |
message = { | |
:subject=> "#{opts[:subject]}", | |
:from_name=> "example corp", | |
:from_email=>"[email protected]", | |
:to=> | |
[{"name"=>"Some User", | |
"email"=>"#{opts[:email]}", | |
"type"=>"to"}], | |
:global_merge_vars => opts[:global_merge_vars] | |
} | |
sending = MANDRILL.messages.send_template opts[:template], [], message | |
rescue Mandrill::Error => e | |
Rails.logger.debug("#{e.class}: #{e.message}") | |
raise | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment