V
V
Vayladion Gognazdiak2014-09-18 11:04:01
Ruby on Rails
Vayladion Gognazdiak, 2014-09-18 11:04:01

ActionMailer + delayed_job doesn't leave mail. What is the reason?

Hello,
The problem is the following. There are 4th rails, sending mail through ActionMailer is implemented.
Then it was necessary to fasten delayed_job, since the mailing is carried out through a large user base (I will say right away - not SPAM). After fastening the DJ, the mail stopped being delivered, while the DJ works correctly (records in the delayed_jobs table appear and then are processed). What is the problem? I sin that the DJ for some reason does not pick up config.action_mailer from production.rb
Thanks in advance for the answer.
Code and log below.
production.rb:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
                                          address:              'mail.xxx.ru',
                                          port:                 25,
                                          domain:               'xxx.ru',
                                          user_name:            '[email protected]',
                                          password:             'XxXxXx',
                                          authentication:       'plain',
                                          enable_starttls_auto: false  
                                        }

mail_controller.rb
def send_some(emails)
                email_subject = ...
                .....
    emails.each do |e|
      PMailer.send_email(e.to_s,email_subject,email_body).deliver
    end
    redirect_to root_path
end

p_mailer.rb:
class PMailer < ActionMailer::Base
  default from: "[email protected]"

  def send_email(email,mail_subject,mail_body)
  	mail(to: email, subject: "#{mail_subject}", body: "#{mail_body}")
  end
  handle_asynchronously :send_email

end

PMailer#send_email: processed outbound mail in 6.2ms
   (0.2ms)  BEGIN
  SQL (0.3ms)  INSERT INTO "delayed_jobs" ("created_at", "handler", "run_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"  
   (0.5ms)  COMMIT

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arkady Butermanov, 2014-10-14
@Arkadey

Go to the console and look at some Delayed::Job.last. Are there attempts_count > 1 or last_error?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question