Postfix Changes HTML Formatting of CDO Email

Posted on 2014-02-14
Last Modified: 2014-02-18
We just migrated to office 365, and in that migration, we started using postfix for our hundres of automated emails.  However, postfix appears to be changing / losing html formatting when sending an email.

I know this is postfix because of the following tests:
All tests use the same page / sample email

Test 1 - Sent from exchange server - normal formatting / email (old method before switchign to O365)
Test 2 - Send using embedded authorization, straight to O365 servers - normal formatting
Test 3 - Send using smtp relay (Postfix), formatting gets jacked up.  An example is hyperlinks, sometimes they work, sometimes they won't, it iwll display the link instead of what is embedded int eh <a></a> tags.  Another example is during tables, a random <td> will show up, or, even worse, it will treat a </tr> as something it isn't, and not all of the data will show up on the email.

It does seem to affect tables more than anythign else, and when htere is a loop of data being displayed.  And, if the results have, for example, 30 results, maybe lines 8 and 24 and 27 will have odd formatting, when the rest are just fine.
Question by:dzirkelb
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4

Author Comment

ID: 39859003
The email is generated from classic asp if that matters.
LVL 78

Expert Comment

ID: 39859136
Is the HTML being passed as an inline attachment?

Or your setup is that the HTML is the message text without specifying content-type?
Is your asp use higher ascii or Unicode characters?  You need to encode (quoted printables or MIME).

Postfix would not alter the HTML. If you have a missing tag, postfix will neither correct it nor fail to transport the message.

Since you are using asP. Configure IIS smtp and transmit a test directly to a recipient to confirm your assumption.

Author Comment

ID: 39859151
Here is the code for a stripped down version of a report that is affected.  The code creates the email, and is the actual body of the email.

we tried iis transport first, but emails were not being sent, just lost in limbo land.

<!-- #include file="dbQS.asp" -->
set rs = Server.CreateObject ("adodb.Recordset")
ssql = "select * from table"
rs.Open ssql, dbc, adOpenForwardOnly, adLockReadOnly

Set obJMail = Server.CreateObject("CDO.Message")
Set objConfiguration = Server.CreateObject("CDO.Configuration")
Set strFields = objConfiguration.Fields

With strFields
      .Item(cdoSendUsingMethod) = 2
      .Item(cdoSMTPServer) = "smtp relay"
      .Item(cdoSMTPServerPort) = 25
      .Item(cdoSMTPconnectiontimeout) = 10
End With
Set obJMail.Configuration = objConfiguration
obJMail.From = ""
obJMail.To = obJMail.To & ";"
obJMail.Subject = "test"
obJMail.HTMLBody = obJMail.HTMLBody & "<table border=""1"">"
obJMail.HTMLBody = obJMail.HTMLBody & "<tr>"
obJMail.HTMLBody = obJMail.HTMLBody & "<th>test></th>"
obJMail.HTMLBody = obJMail.HTMLBody & "</tr>"

do while not rs.eof
      obJMail.HTMLBody = obJMail.HTMLBody & "<tr>"
      obJMail.HTMLBody = obJMail.HTMLBody & "<td><a href="""&rs("test")&""">"&rs("test")&"</a></td>"      
obJMail.HTMLBody = obJMail.HTMLBody & "</tr>"

set rs=nothing

set dbc=nothing

obJMail.HTMLBody = obJMail.HTMLBody & "</table>"
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 78

Expert Comment

ID: 39859243
The code means nothing as the issue is with the rendering.

Generate the HTML and then see if the output validates for HTML.

Note some apps through which you vie HTML are strict! I.e. Hey interpret and render explicitly. Others are more liniment I.e. A <tr> without a  preceding </Td> Will be interpreted/rendered as an error on the strict opening a row in the table cell while a liniment will "close" the preceding table cell to open a new row (will treat <tr> as </td><tr>.

Author Comment

ID: 39859272
Exactly, code should mean nothing with postfix.  But, regardless of if it renders correct, strict, or not, the fact remains that wehen I send this using our exchange server, the email is fine.  When i send it via smtp postfix relay, the formatting isseus are present.

So, I fail to see how if even the html validates is goign to find a solution to this problem, and I'm 99% confident it will not pass the w3 standards as it's nto meant to, it's not a web page.
LVL 78

Accepted Solution

arnold earned 500 total points
ID: 39859365
The encoding of the content is the only place where postfix interacts it in no way deals with HTML content.

Your transport via exchange uses Unicode transform, while your transmission via postfix uses 8bitmime transform.

Use a test to transmit the same report via excahnge and postfix and then compare the raw data (message source) HTML to see whether it deviates in any way.

If you send a mailing via uos and one over usps, then say that when you send through one the content is there, but through the other the content was modified.

Postfix will transport the data the way it is.

Author Comment

ID: 39859428
They do differ.  On the postfix source it shows this:


At the very end of the source, and the exchagne shows this:


which is exactly where the odd format kicks in.  And, this page has 56 <td> tags, it only changes the <td> to &lt; td&gt; on one of them.

Can we make postfix transport via unicode?
LVL 78

Expert Comment

ID: 39859720
Yes, you have to make sure your ASP code encodes it in unicode or MIME.

unicode merely means that u+003E replaces the character >.

try this.

copy the text of your HTML in its entirety as you get it from exchange.

The check is whether the issue is with the greating. i.e. helo originatingservername tells postfix to use the standard SMTP interchange. while ehlo originatingservername tells postfix to use the enhanced SMTP interchange.
you will send two identical message with the only variation being the greeting.
once you will use the older helo originatingserver and the other you will use ehlo originatingserver

Then using a telnet session:

telnet postfix 25

mail from: <youremailaddress>
rcpt to: <youremailaddress
From: youremailaddress
To: youremailaddress
Subject: sending using <greeting>

HTML CODE paste here

See whether that makes a difference.

NOTE THAT the presumption here is that there will be no single period on line.

in SMTP interaction, a single . on a line means end of message.

Author Comment

ID: 39859991
I'm unable to connect to postfix via telnet, says can't open on port 25, but that's the port we send email on.
LVL 13

Expert Comment

ID: 39863972
Check you might be using SMTP over SSL.

Author Closing Comment

ID: 39867487
We ended up getting our IIS SMTP server to work (there was a firewall issue), and the emails do not lose or have anything changed on them.

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Migrating a Linux server to VMware 3 112
EXCH2013 - copy config to 3rd server 6 50
Linux MD5 Hash 7 65
plsql job on oracle 18 78
Fine Tune your automatic Updates for Ubuntu / Debian
Pop culture is prime bait for hackers seeking to infect user’s computers and mobile devices with malicious malware. Hackers know exactly what the latest trends are online and know how to use them to their advantage.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question