So I want a way of storing sent emails inside of the database for future reference. I've hooked into the MessageSending event and am using the following handle in my listener.
I don't see any reason to assume its a bad way.
We use it the same method but use a column called : full_email with type LONGTEXT. Includes the full email with the full html. This way you wont destroy the full layout of the email.
How do you wanna handle attachments in an email?
Also dont forget to save the flags like "READ" , "UNREAD" , "NEW".
Hadn't thought about recording attachments but now that you mention it, that would be useful as well.
I was doing this just to record basic emails but we often send emails to users with statements and invoices attached so would be good to see the email exactly how it's sent.
Also, although I am recording the 'to' part of the email, I would like to link the email to the user(s) by the way of a pivot table but i'm wondering how to get the $user automatically?
Is there any way to get the user from the 'to' later on? I know I could add $user to the OrderShipped example but was wondering if there was an easier, more fluid/automatic way.
This would be so I could attach the email and user via a pivot table in case they ever changed their email address.