@@ -717,12 +717,22 @@ method of the ``TemplatedEmail`` class and also to a special variable called
717
717
Text Content
718
718
~~~~~~~~~~~~
719
719
720
- When the text content of a ``TemplatedEmail `` is not explicitly defined, mailer
721
- will generate it automatically by converting the HTML contents into text. If you
722
- have `league/html-to-markdown `_ installed in your application,
723
- it uses that to turn HTML into Markdown (so the text email has some visual appeal).
724
- Otherwise, it applies the :phpfunction: `strip_tags ` PHP function to the original
725
- HTML contents.
720
+ When the text content of a ``TemplatedEmail `` is not explicitly defined, it is
721
+ automatically generated from the HTML contents.
722
+
723
+ Symfony uses the following strategy when generating the text version of an
724
+ email:
725
+
726
+ * If an explicit HTML to text converter has been configured (see
727
+ :ref: `twig.mailer.html_to_text_converter
728
+ <config-twig-html-to-text-converter>`), it calls it;
729
+
730
+ * If not, and if you have `league/html-to-markdown `_ installed in your
731
+ application, it uses it to turn HTML into Markdown (so the text email has
732
+ some visual appeal);
733
+
734
+ * Otherwise, it applies the :phpfunction: `strip_tags ` PHP function to the
735
+ original HTML contents.
726
736
727
737
If you want to define the text content yourself, use the ``text() `` method
728
738
explained in the previous sections or the ``textTemplate() `` method provided by
@@ -732,13 +742,13 @@ the ``TemplatedEmail`` class:
732
742
733
743
+ use Symfony\Bridge\Twig\Mime\TemplatedEmail;
734
744
735
- $email = (new TemplatedEmail())
736
- // ...
745
+ $email = (new TemplatedEmail())
746
+ // ...
737
747
738
- ->htmlTemplate('emails/signup.html.twig')
748
+ ->htmlTemplate('emails/signup.html.twig')
739
749
+ ->textTemplate('emails/signup.txt.twig')
740
- // ...
741
- ;
750
+ // ...
751
+ ;
742
752
743
753
.. _mailer-twig-embedding-images :
744
754
0 commit comments