如何序列化和反序列化邮件? [英] How to serialize and deserialise mailers?

查看:209
本文介绍了如何序列化和反序列化邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



序列化的数据应该是断开连接的,并且足够自动发送到分开的机器上应该传递这个消息(不知道数据库或其他任何东西)。

解决方案

假设你通常会发送电子邮件:

  MyMailer.some_email(...)。交付

相反,您可以将其转换为字符串并将字符串传输到另一台服务器:

  raw_mail = MyMailer.some_email(...)to_s 

在另一台服务器上,发送电子邮件:

  Mail.new(raw_mail).deliver 


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

解决方案

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

这篇关于如何序列化和反序列化邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆