Dmytrii Nagirniak
Dmytrii Nagirniak

Reputation: 24108

How to serialize and deserialise mailers?

How can I serialise the mailer so that it can be stored for further use?

The serialised data should be disconnected and self sufficient to be delivered on separate machine that should deliver that message (not knowing about database or anything else).

Upvotes: 5

Views: 835

Answers (1)

Yanhao
Yanhao

Reputation: 5294

Suppose you usually send emails with this:

MyMailer.some_email(...).deliver

Instead delivering it, you can convert it to a string and transfer the string to another server:

raw_mail = MyMailer.some_email(...).to_s

On another server, send the email:

Mail.new(raw_mail).deliver

Upvotes: 7

Related Questions