I’ve had scenarios before where the users of an application want access to mail sent out through the application. Fortunately, it’s easy to craft an Observer to store a quick copy of the mail object.
A few notes:
- It’s possible to just serialise the
messageobject directly. Storing the attributes makes it easier to query the
- Most of the fields on
message.from) act or display like arrays or strings, but are actually instances of classes like
Mail::AddressContainer. They’ll respond to most array or string commands.
- In multipart emails,
message.bodywill not be sufficient to retreive the body. You might need to use
message.partswill retrieve all parts (including eg. attachments), and is an instance of
Mail::PartsList. It behaves like an array.