Rails: Held Job & # 8594; Do not collect the out field when sending asynchronous mail

I am running 2.1.1, Rails 3 and have heckuva time, getting work with delayed_job puff. If I separate handle_ asynchronously from the mail program, everything works fine ... but if I return it, I will get:

undefined `name 'method for nil: NilClass (where' name 'comes from @ contact.name ... which works fine when handle_asynchronously is disabled).

If I delete all the information about the @contact template, I get:

"Sender (Return-Path, Sender or From) required to send a message?"

Am I doing something wrong or something? Relevant code below ( my@email.here replaced by legal email address)

class ContactMailer < ActionMailer::Base
  default :from => "my@email.here"  

  def contact_mail(contact)
    @contact = contact
    mail(:to => ENV['MANAGER_EMAIL'], :subject => 'Delayed Job Test', :from => 'my@email.here', :content_type => 'text/plain')
  end

  handle_asynchronously :contact_mail, :run_at => Proc.new { 2.seconds.from_now }
end

Any suggestions are greatly appreciated.

+3
3

:

def contact_mail(contact_email)
  mail(:to => ENV['MANAGER_EMAIL'], :subject => 'Delayed Job Test', :from => contact_email, :content_type => 'text/plain')
end

, , , . , nil, , .name...

+2

, :

default :from => "my@email.here" 

, .

0

Rails 3 Mailers

- , Rails 3, , delayed_job.

# without delayed_job
Notifier.signup(@user).deliver

# with delayed_job
Notifier.delay.signup(@user)

.deliver, . , ,

https://github.com/collectiveidea/delayed_job#rails-3-mailers

0
source

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


All Articles