How to serialize and deserialise mailers?

南楼画角 提交于 2019-12-10 14:48:42

问题


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).


回答1:


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


来源:https://stackoverflow.com/questions/13264424/how-to-serialize-and-deserialise-mailers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!