MS Entourage 2008 and quoted-printable encoding - email

I need to send an HTML email. All email clients (Outlook, Thunderbird ..) but Entourage can receive and read this email without major problems. Entourage, though is breaking the content and displays just few lines from the beginning.
My guess is that it has something to do with the way how Entourage handles quoted-printable encoding. The important headers of email as they are set:
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
The same behaviour in Entourage occurs when email is sent as multipart/alternative with alternative plain text.
The content of the email is displayd until the character =00 occurs (encoded NUL?).
Is this Entourage bug behaviour? Or am I doing something wrong?

The problem is indeed those *=00* characters. Before sending the email, you need to prepare it for quoted-printable encoding and remove all null characters.
$str = preg_replace('/\x00+/', '', $str);

Related

What is the proper non ascii (UTF-8) email message text encoding in a multipart message

I would like to send an email message with attachments. So the message should be multipart.
The encoded message body looks like:
From: another#address
To: an#address
Subject: Unimportant message
Content-Type: multipart/mixed; boundary="----=_Part_0_1457006650.1670256299458"
...
------=_Part_0_1457006650.1670256299458
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Hello,
=E2=80=9ESomething here=E2=80=9C
------=_Part_0_1457006650.1670256299458
Content-Type: image/png; name=sample.png
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=sample.png
Content-Description: sample.png
iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9
...
FElEQVQY02P8z8WABzAxMIxKYwIATTQBHSBDi6AAAAAASUVORK5CYII=
------=_Part_0_1457006650.1670256299458--
Web MS Outlook and Gmail do not display non ASCII characters correctly showing a placeholder for each UTF-8 byte in the message body. For example:
I tried different Transfer-Message-Encoding values and different multipart layouts (multiple top-level sections, and nested as parts inside the root-multipart) but the result seem the same - it seems that Web Outlook does take into account the transfer encoding, but does not recognize the message text encoding as UTF-8.
Is this a problem with Outlook Web? Or the message should have some additional meta information or different multipart layout?
I probably could use an HTML encoding, but the message is generated from a template, so all non-ASCII symbols will have to be converted to entities automatically, if I understand correctly. We do not need any fancy formatting besides plain text message, so that option seems over-complicated.

How to manage Encoding Problems with äöü in email send through smtp?

I have send an email äöü in E-Mail Notifications (Video Title) Example: Vielseitigkeit-Europameisterschaft 2011: Freya Fllgraebe 1 ist nun in der Kategorie.thats word äöü is changes into Fllgraebe.How to remain same äöü when we send mail through smtp in php?
The MIME specifications define various encoding algorithms for this depending on whether the text appears in the message body, one of the message headers, or in parameters to the Content-Type/Content-Disposition headers (such as filename).
All of the MIME specifications are hosted on www.ietf.org. For a set of quick links, check out https://github.com/jstedfast/MimeKit/blob/master/RFCs.md
Add some headers to you e-mail declaring the encoding you are using. Assuming you are using UTF-8 use the following headers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

What is the best way to send the original email message quoted in a response?

Should I prepend all lines with '> '? Is that sufficient? Will it be accepted and understood by all major email clients?
In this case will a original.replace(/\n/g, '\n> ') regex replacement do what I want with the message?
What about the HTML version of the email? Use a big <blockquote>? Just prepending a <blockquote> and appending a </blockquote> will suffice?
Should I, like Gmail and others, prepend a line saying something like "someone <address#example.com> wrote at some time:"?
Plain text and by that I mean: Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
just requires ">" to quote the previous message (1 per line).
HTML version - depends on the client you're rendering in.

Is Content-Transfer-Encoding needed for multipart/alternative Content-Type?

I have an app that sends e-mails and for many months, it was working fine. I recently had problems with utf-8 encoded emails sent to iPhone Exchange account (i.e. not IMAP).
All the receiver had to see was a big bunch of meaningless characters like LS0tLS0tPV9QYXJ0XzE0N18[....].
Comparing my email headers with Gmail, I noticed that I had an extra Content-Transfer-Encoding associated with the Content-Type: multipart/alternative;.
My email would look like
Delivered-To: ...
Received: ...
...
MIME-Version: ...
Content-Type: multipart/alternative;
boundary="----=_boundary"
Content-Transfer-Encoding: Base64 # <= the extra setting
----=_boundary
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: Base64
YmVu0Cg==
----=_boundary
Content-type: text/html; charset=utf-8
Content-Transfer-Encoding: Base64
PGh0bWwgeG1sbnM6bz0iIj48aGVhZD48dGl0bGU+PC90aXRsZT48L2hlYWQ+PGJvZHk+YmVub2l0
PC9ib2R5PjwvaHRtbD4NCjx9IjAiIC8+Cg==
----=_boundary
If I remove the extra setting, my email is received and display properly.
My questions:
Is the Encoding setting basically needed with Content-Type: multipart/alternative;, even for specific cases ?
Is it safe to remove it and just keep using my app as I used to ?
Edit
I found on IETF:
Encoding considerations: Multipart content-types cannot have encodings.
But I also found on Wikipedia:
The content-transfer-encoding of a multipart type must always be
"7bit", "8bit" or "binary" to avoid the complications that would be
posed by multiple levels of decoding.
Isn't it contradictory ?
The statements from IETF and wikipedia aren't really contradictory. 7bit, 8bit, or binary aren't really content encodings in that they don't specify any transformation of the content. They simply state that the content hasn't been encoded. In the case of 7bit it also specifies that the content doesn't need to be encoded even if the message needs to be sent over a transport that isn't 8-bit clean.
Only the bottom-most layers of messages should have an actual Content-Transfer-Encoding such as base64 or quoted-printable. In the message that you quote from the outer portion certainly isn't base64 encoded, so stating that it is was not only violating the standard but also incorrect. That would certainly be expected to cause problems with display of that message.
In practice, each part of a multipart has its own encoding, and it doesn't make sense to declare one for the multipart container. I cannot make sense of the Wikipedia quote anyway; in any event, it is hardly authoritative.

ATTnnnnn.txt attachments when e-mail is received in Outlook

I've written an SMTP client that sends e-mails with attachments. Everything's fine except that when an e-mail sent by my program is received by Outlook it displays two attachments - the file actually sent and a file with two characters CR and LF inside and this file has name ATT?????.txt.
I've done search - found a lot of matches like this for similar problems and checked everything I could. Even more - I compared two emails - sent by my program and sent by Opera and I can't deduce the difference. However what Opera sends is interpreted correctly, but what my program sends is not. What my program sends is interpreted by a set of other mail clients correctly, but not by Outlook.
I've telnet'et to the SMTP server, retrieved the two emails into a text file - one from my program, another from Opera, and compared them side-by-side. I didn't see any difference that could affect interpretation by an email client.
Here's a sample message (addresses substituted, file contents cropped, blank lines exactly as they appear in real messages, lines never exceed 80 characters):
To: user1#host.com, user2#host.com
Subject: subject
Content-Type: multipart/mixed; boundary="------------boundary"
MIME-Version: 1.0
--------------boundary
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
here goes the Base64 encoded text part - it may be localized, so
it's better to UTF8 it and do Base64
--------------boundary
Content-Disposition: attachment; filename="file.jpg"
Content-Type: application/octet-stream; name="file.jpg"
Content-Transfer-Encoding: base64
here goes the Base64 encoded file data
--------------boundary
I tried to play with linebreaks after the last boundary - tried none, one, two, three, but this doesn't improve the situation.
Is there a set of some weird limitations that a mail client must follow to produce messages that are interpreted by Outlook correctly?
The last boundary of a MIME part must be indicated by appending two dashes:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------boundary"
--------------boundary
...
--------------boundary
...
--------------boundary--
More reading here: RFC1341 / 7.2 The Multipart Content-Type