Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何序列化邮件程序以便可以存储以供进一步使用?
序列化的数据应该断开连接并且自给自足,以便在应该传递该消息的单独机器上传递(不知道数据库或其他任何东西)。
假设您通常使用以下内容发送电子邮件:
MyMailer.some_email(...).deliver
您可以将其转换为字符串并将字符串传输到另一台服务器,而不是交付它:
raw_mail = MyMailer.some_email(...).to_s
在另一台服务器上,发送电子邮件:
Mail.new(raw_mail).deliver