Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML vs Plain text as body in email

Tags:

When creating a Swift_Message you can have both a plain text and an html version of the email. You set one as the body, and then you add the other one as a part.

What is the difference if I set the HTML version as body and plain text as part, and the other way around?

$html_as_body = Swift_Message::newInstance()     ->setSubject($subject)     ->setBody($html, 'text/html')     ->addPart($plain, 'text/plain');  $plain_as_body = Swift_Message::newInstance()     ->setSubject($subject)     ->setBody($plain, 'text/plain')     ->addPart($html, 'text/html'); 

And by difference, I mean what kind of difference will it have in email readers and such?

like image 782
Svish Avatar asked Jun 11 '12 19:06

Svish


People also ask

What is the difference between text and HTML emails?

An HTML email contains images, colors, and other text formatting. A plain text email contains only text without any formatting. The important difference is the lack of formatting and rendering in the text. Some email services like Gmail appear to be plain text but are HTML emails.

Why do plain text emails perform better?

Spam filters prefer plain text email because they will have a more legitimate sender. As a result, your plain text emails will fly through the spam filters and land straight into your users' inboxes. Spam filters can get hung up on HTML code and misinterpret its integrity.

Should you email plain text?

Even when you're sending out an HTML email, a plain text email version is crucial. Multi-part MIME (Multipurpose Internet Mail Extensions)—the protocol that allows for sending all of our email marketing campaigns—bundles together a simplified plain text version of your email along with the HTML version of your email.


1 Answers

There should be no difference, if only Swift_Message follows official RFC for mail compose, which (AFAIK) strictly sets that plain-text message should be default (first, body) and eventually followed by HTML version.

Make some tests, i.e. sent the same e-mails in both configurations and see in receiving client what is the source of your message.

If you see any difference, then in IMHO you should definitely send plain text body (first) and HTML version last. As even nowadays there are many simple mail clients, which will simple ignore / not properly recognize HTML version. So, if you put it as first, there is a chance that whole message will be unreadable for the receiver.

like image 91
trejder Avatar answered Oct 22 '22 15:10

trejder