Malformed email header by CRM 3.0?

                                  

I have been spending sometime  troubleshooting a production issue for a client .

Background:

This is a CRM 3.0 implementation. When a member of public fills up a web form to inform the client of a gas or electricity incident, it calls upon CRM WebService to create a custom entity “Incident” in CRM to capture some information. This in turn, triggers a workflow sending an email with the incident details to DMZ Global. DMZ Global will then interrogate this message, package it up and send it onto Telecom’s eTxt. eTxt will then send it off to a pager that’s on call.

Lost yet? Essentially, a message that’s entered through a web page will jump through a few hops and get sent to a pager.

Problem:

The messages will choose to arrive at the pager as they please.

i.e.; The messages will arrive sometimes and not others, there is no obvious patterns in why some arrives while others don’t.

Investigation:

We were able to pick up some traces for a few failed and successful messages through the full route.

Client Website -> Client SMTP servers -> DMZ Global -> Telecom eTxt  -> Pager

We came to realise that the ones that DID arrive at the pager has the following Email Headers.

From: =?utf-8?B?Q1JNX0ludGVyYWN0aXZlIFBSRCBTeXN0ZW0gQWNjb3VudAA==?= <energysafety@client.com>

The ones that did NOT arrive at the pager have this following Email Headers.

From: =?utf-8?B?Q1JNX0ludGVyYWN0aXZlIFBSRCBTeXN0ZW0gQWNjb3VudAA=pre>?= <energysafety@client.com>

Thanks to this free online decoder. UTF-8 Base 64 string

Q1JNX0ludGVyYWN0aXZlIFBSRCBTeXN0ZW0gQWNjb3VudAA==

translates to

CRM_Interactive PRD System Account

This is the first and last name specified in CRM for a System Administrator account. In this instance, the workflow that sends out emails is executed under the security context of this account.

A couple of interesting observations;

1. The names are UTF-8 Base 64 encoded by CRM.

2. There is a incomplete pre> tag that’s injected towards the end of this encoded string.

One other point of interest is, when I change the first and last name to “Energy” “Safety” respectively. The from Email header will NOT be encoded;

From: "Energy Safety" <energysafety@client.com>

A couple of questions we asked ourselves were,

1. Why are some names UTF-8 based 64 encoded by CRM and not others?

2. Where did this incomplete Pre> tag got injected into the from address?

It’s confirmed that DMZ Global will conditionally inject <Pre> tags based on its ways of determining if the message is HTML based. Its parsing mechanism may have mistaken this UTF-8 Base 64 encoded string as HTML and somehow inject this incomplete Pre> tag into it. However, I’m not ruling out that the two internal SMTP servers may have been the culprit here.

Resolution:

Since the root cause of all is the name is UTF-8 Based 64 encoded. So we decided to make CRM NOT encode it, we achieved this by changing the first and last names in CRM to single word;

image

This prevented CRM from encoding the names with UTF-8 Base 64 and therefore prevented the SMTP Servers or DMZ Global from *sporadically* injecting this incomplete Pre> tag into the from email header.

Lessons Learnt

1. CRM 3.0 WILL encode the email addressees’ names with UTF-8 Base 64 if you have special characters like ‘_’ (I can’t find anything on CRM encoding email address names in the header, can anyone pin down an article that describes when it encodes them and when it doesn’t?)

2. The SMTP servers or DMZ Global MAY see the encoded string as HTML and decides to inject an incomplete Pre> tag, ONLY THEN, it becomes a malformed email header and Telecom’s eTxt will understandably fail to parse it out and send it onto the pager.

peculiar.

Advertisements

One response to this post.

  1. […] – bookmarked by 4 members originally found by CookieStroke on 2008-07-31 Malformed email header by CRM 3.0? https://sundium.wordpress.com/2008/07/23/malformed-email-header-by-crm-30/ – bookmarked by 1 […]

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: