nette / mail

A handy library for creating and sending emails in PHP
https://doc.nette.org/mailing
Other
469 stars 71 forks source link

Message serializator #80

Closed janbarasek closed 3 years ago

janbarasek commented 3 years ago

Hello,

I think there should be an official way for Message to serialize it to a string, for example. There should also be a method that converts the serialized string back to a Message instance with the same content.

This feature can be useful when storing messages in a database and sending them through a queue.

The serialized Message should be without attachments (only a reference to the disk path, or omit completely) and be stored as a simple string including headers.

For example:

To: Jan <jan@barasek.com>
From: Nette <info@nette.org>
Subject: My awesome message!

<!-- HTML body -->
<p>Hello, how are you?</p>

Text content does not have to be included, because we can always calculate it from HTML.

Thank you.

dg commented 3 years ago

To serialize you can use $message->build()->getEncodedMessage(). I have no plans to develop an email parser.

janbarasek commented 3 years ago

OK I understand. I implemented it on the side of my own package.

Thanks.