Rails3 Beta4 Devise Delayed_job configuration
I want to use delayed_job to send email in backend, this is /config/initializers/setup_mail.rb
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => DOMAIN,
:user_name => USERNAME,
:password =>开发者_开发技巧; PASSWORD,
:authentication => "plain",
:enable_starttls_auto => true
}
so I want to know how to configure the delayed_job to send mail in backend.Thank you.
you should use action mailer tutorial first http://edgeguides.rubyonrails.org/action_mailer_basics.html then just mark your mail for performing in delayed_job:
class UserMailer < ActionMailer::Base
default :from => "notifications@example.com"
def welcome_email(user)
@user = user
@url = "http://example.com/login"
mail(:to => user.email,
:subject => "Welcome to My Awesome Site")
end
handle_asynchronously :welcome_email
end
You can also call handle asynchronously in config:
UserMailer.handle_asynchronously :welcome_email
This site walks through the whole process: http://www.magnionlabs.com/2009/2/28/background-job-processing-in-rails-with-delayed_job
Unless I'm misunderstanding what you're asking?
Take a look at this: http://xponrails.net/2011/03/04/how-to-send-email-asynchronously-using-devise-and-rails3/
Worked for me ...
精彩评论