Created
November 22, 2011 01:38
-
-
Save darcyclark/1384630 to your computer and use it in GitHub Desktop.
sending emails asynchronously from Padrino via Resque
This file contains hidden or 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
# put this in /lib/resque.rb | |
require 'mail' | |
module Emailer | |
class Send | |
@queue = :issue_mailer | |
def self.perform(addressee, subject, body) | |
Mail.defaults do | |
delivery_method :smtp, { | |
:address => "smtp.gmail.com", | |
:port => 587, | |
:domain => '***', | |
:user_name => '***', | |
:password => '***', | |
:authentication => 'plain', | |
:enable_starttls_auto => true | |
} | |
end | |
mail = Mail.new do | |
from "***" | |
to addressee | |
subject subject | |
content_type "text/html; charset=UTF-8" | |
body body | |
end | |
mail.deliver! | |
end | |
end | |
end | |
# then call asynchronously from controller via: | |
Resque.enqueue(Emailer::Send, addressee, subject, body) |
Thank you! That works.
thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for info on installing and configuring Resque - see here https://github.com/defunkt/resque