Setting up Rails3 Beta4 Devise Delayed_job

I want to use delayed_job to send email to the 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 delayed_job to send mail to backend.Thank.

+3
source share
3 answers

you must first use the tutorial on the mail program http://edgeguides.rubyonrails.org/action_mailer_basics.html , and then just mark your mail for execution 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 the descriptor asynchronously in config:

UserMailer.handle_asynchronously :welcome_email
+1
source

Source: https://habr.com/ru/post/1753040/


All Articles