@@ -102,28 +102,27 @@ use Zend\Mime\Part as MimePart;
102102
103103$body = new MimeMessage();
104104
105- $text = new MimePart($textContent);
106- $text->type = Mime::TYPE_TEXT;
107- $text->charset = 'utf-8';
105+ $text = new MimePart($textContent);
106+ $text->type = Mime::TYPE_TEXT;
107+ $text->charset = 'utf-8';
108108$text->encoding = Mime::ENCODING_QUOTEDPRINTABLE;
109109
110- $html = new MimePart($htmlMarkup);
111- $html->type = Mime::TYPE_HTML;
112- $html->charset = 'utf-8';
110+ $html = new MimePart($htmlMarkup);
111+ $html->type = Mime::TYPE_HTML;
112+ $html->charset = 'utf-8';
113113$html->encoding = Mime::ENCODING_QUOTEDPRINTABLE;
114114
115115$content = new MimeMessage();
116+ // This order is important for email clients to properly display the correct version of the content
116117$content->setParts([$text, $html]);
117118
118119$contentPart = new MimePart($content->generateMessage());
119- $contentPart->boundary = $content->getMime()->boundary();
120- $contentPart->type = 'multipart/alternative';
121120
122- $image = new MimePart(fopen($pathToImage, 'r'));
123- $image->type = 'image/jpeg';
124- $image->filename = 'image-file-name.jpg';
121+ $image = new MimePart(fopen($pathToImage, 'r'));
122+ $image->type = 'image/jpeg';
123+ $image->filename = 'image-file-name.jpg';
125124$image->disposition = Mime::DISPOSITION_ATTACHMENT;
126- $image->encoding = Mime::ENCODING_BASE64;
125+ $image->encoding = Mime::ENCODING_BASE64;
127126
128127$body = new MimeMessage();
129128$body->setParts([$contentPart, $image]);
0 commit comments