Skip to content

Instantly share code, notes, and snippets.

@joshuachestang
Last active November 24, 2015 18:09
Show Gist options
  • Save joshuachestang/9437661 to your computer and use it in GitHub Desktop.
Save joshuachestang/9437661 to your computer and use it in GitHub Desktop.
Using SendWithUs with Custom Devise Mailer and sendwithus_ruby gem
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