8000 Documented the Mime component by javiereguiluz · Pull Request #11280 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Documented the Mime component #11280

8000
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Prev Previous commit
Next Next commit
Added a section about serializing messages
  • Loading branch information
javiereguiluz committed Apr 3, 2019
commit 69ff0e20a86b0aaae7906ab4b1eee8e44c5c44c0
30 changes: 30 additions & 0 deletions components/mime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,34 @@ email multiparts::

$email = new Message($headers, $messageParts);

Serializing Email Messages
--------------------------

Email messages created with either the ``Email`` or ``Message`` classes can be
serialized because they are simple data objects::

$email = (new Email())
->from('fabien@symfony.com')
// ...
;

$serializedEmail = serialize($email);

If you want to store serialized email messages to recreate them later (e.g. to
include them in a message sent with the :doc:`Messenger component
</components/messenger>`) use the ``toString()`` utility method and the
:class:`Symfony\\Component\\Mime\\RawMessage` class::

use Symfony\Component\Mime\RawMessage;

// create the email and serialize it for later reuse
$email = (new Email())
->from('fabien@symfony.com')
// ...
;
$serializedEmail = $email->toString();

// later, recreate the original message to actually send it
$message = new RawMessage($serializedEmail);

.. _`MIME`: https://en.wikipedia.org/wiki/MIME
0