Last active
November 24, 2015 18:09
-
-
Save joshuachestang/9437661 to your computer and use it in GitHub Desktop.
Using SendWithUs with Custom Devise Mailer and sendwithus_ruby gem
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 AuthMailer < Devise::Mailer | |
require 'rubygems' | |
require 'send_with_us' #after installing sendwithus_ruby gem, require the send_with_us.rb initializer file | |
helper :application # gives access to all helpers defined within `application_helper`. | |
include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url` | |
default from: "[email protected]" | |
def confirmation_instructions(record, token, opts={}) | |
begin | |
result = SendWithUs::Api.new.send_with('place your send_with_us api key here', | |
{ address: record.email }, | |
{ confirmation_email: confirmation_url(record, :confirmation_token => token) }) | |
puts result | |
rescue => e | |
puts "Error - #{e.class.name}: #{e.message}" | |
end | |
end | |
def reset_password_instructions(record, token, opts={}) | |
begin | |
result = SendWithUs::Api.new.send_with('place your send_with_us api key here', | |
{ address: record.email }, | |
{ email: record.email, reset_password_link: edit_password_url(record, :reset_password_token => token) }) | |
puts result | |
rescue => e | |
puts "Error - #{e.class.name}: #{e.message}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment