Sending email with attachments asynchronously with delayed_job

I use delayed_job to send a greeting message asynchronously, and it seems that the attachments in my email are not sent when I delay them.

If I use the code UserMailer.welcome_email(@user).deliver , the message will be sent with attachments, and the logs indicate that the message is sent as a multi-page letter.

But if I use the code UserMailer.delay.welcome_email(@user) , the mail will be sent, but without attachments, and the logs do not indicate that the message is sent as a multi-page letter.

Do I need to set up something special for it to work? I am on Rails 3.0.9 and delayed_job 2.1.4.

Thanks!

+4
source share
1 answer

I discovered what happened.

In my mailer, I did not have the string content_type "multipart/mixed" , since I thought the mail stone would automatically handle this, as described in http://guides.rubyonrails.org/action_mailer_basics.html#adding-attachments .

It turns out that the mail descriptor descriptor will work when I do not postpone sending emails, but it does not work when I delay it. Adding content_type "multipart/mixed" to my email program solves the problem.

However, I'm not sure if this is an error with delayed_job, or I have a missing configuration.

+4
source

All Articles