Why won't Outlook use the text/plain part?
Asked Answered
M

1

3

First of all, hello,

With SwiftMailer, i'm sending HTML+PLAIN emails.

On outlook, when displaying this email as plain text, this is not my plain text part showing up, but a automatic parsed version of the HTML.

Does anyone know how to force Outlook to use the text/plain part of message when displaying plain text?

My code does the following:

$plain_body = convert_html_to_text($body);
$message->setBody($body, 'text/html')
->addPart($plain_body, 'text/plain');

$body has some formatting and images:

vardump($body);

<html>
<head>...</head>
<body>
<img src="logo.png" alt="Company name" /><br />
<img src="border.png" alt="border" /><br />
<img src="face.png" alt="Mr Somebody" /><br />
<p>Hello Ninj!

You requested a confirmation by email...</p>
<img src="footer.png" alt="footer" />
</body></html>

$plain_body contains a very clean text (thanks javon):

vardump($plain_body);

"Hello Ninj!

You requested a confirmation by email..."

But in the plain text version viewed in Outlook, i see instead all the alt attributes of pics of the HTML version, one by line, then some lightly formatted text:

Company Name

border

Mr Somebody

Hello Ninj!

You requested a confirmation by email...

Footer

Thank you by advance for everyone able to help :)

Madonna answered 2/10, 2013 at 11:3 Comment(0)
N
5

Can't do that. Outlook keeps all 3 body flavors (HTML, RTF, plain text) in sync. This is done on the store provider level.

When it receives a MIME message, it uses the HTML body (if available). When the message is saved, the store provider uses the HTML body to generate the plain text body (PR_BODY property).

Nord answered 2/10, 2013 at 17:39 Comment(3)
Thank you for answering, allow me to try to go further: why should we then include a text/plain version of the text if Outlook do not care about it? Isn't this alternative body made for that very purpose: show up instead of HTML when HTML is not rendered?Madonna
If you are sending to Outlook, plaint text won't do anything unless it is the only body part. Remember that Outlook does not store the messages in MIME format. Once a message is received from a POP3/IMAP4/etc. server and stored in an Outlook store, Outlook has no memory where the message came from and what its MIME format was.Nord
@Ninj: There is not only Outlook out there; other clients will use the text/plain part. SpamAssassin dislikes mails which are HTML-only.Buntline

© 2022 - 2024 — McMap. All rights reserved.