jdog
jdog

Reputation: 2549

exchange server inserts unicode characters into plaintext email?

I have an email, sent by phpmailer using plaintext.

When this email is sent through php mail(), I get the exact email. When the email is sent through Exchange on Small business server it appears to insert unicode characters at some points. Example source code as received by email program:

php mail:

MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="utf-8"

Dear J,

This is confirmation of your registration.

Event: Green City Dialogues: Toward a sustainable built environment in Christchurch (2):     Green City Dialogues 2
Date: Monday, 19 September 2011 05:15 pm - 08:00 pm
Attendee: J D

Exchange server:

MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8"
X-TM-AS-Product-Ver: SMEX-10.1.0.1137-6.500.1024-18326.006
X-TM-AS-Result: No--12.011100-0.000000-31
X-TM-AS-User-Approved-Sender: Yes
X-TM-AS-User-Blocked-Sender: No
X-DSPAM-Check: by xxx.xxx.xxx on Wed, 17 Aug 2011 11:59:06 +1200
X-DSPAM-Result: Innocent
X-DSPAM-Processed: Wed Aug 17 11:59:06 2011
X-DSPAM-Confidence: 0.5596
X-DSPAM-Probability: 0.0000

Dear xxxxx,

This is confirmation of your registration.

Event:=A0Green City Dialogues: Toward a sustainable built environment in Ch=
ristchurch (2): Green City Dialogues 2
Date: Monday, 19 September 2011 05:15 pm - 08:00 pm

Upvotes: 0

Views: 499

Answers (3)

jdog
jdog

Reputation: 2549

It turns out that the plaintext email through the Unix server contains the a0 character as well and it is filtered out by Gmail, even in the source code view.

The problem was

html_entity_decode($result['introtext'])

The fix

html_entity_decode($result['introtext'],ENT_COMPAT,'UTF-8')

Upvotes: 0

symcbean
symcbean

Reputation: 48367

Content-Transfer-Encoding: 8bit

SMTP does not (usually) support 8bit data.

I'm not overly familiar with phpmailer() - but I'm very surprised that it should be creating an 8bit email.

MS-Exchange may not be my favourite MTA, but in this instance it seems to be correctly cleaning up your email.

AFAIK there is no MTA called "php mail" - so I'm not sure what you're actually comparing the MS-Exchange processed email with.

Upvotes: 0

Álvaro González
Álvaro González

Reputation: 146490

The U in UTF-8 stands for Unicode. Since you use this in your code:

Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="utf-8"

... you are already sending Unicode characters.

I understand you actually refer to this: =A0. According to headers:

Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8

... it is a plain ASCII representation of your Unicode character. Which is fine: Exchange is simply fixing your e-mail message so it can successfully go through e-mail systems that cannot handle 8-bit messages. Actually, you should do it yourself if you want to accomplish maximum compatibility. In any case, the message content remains the same. It's just a temporary encoding to transmit it.

Upvotes: 1

Related Questions