Go Premium for a chance to win a PS4. Enter to Win


Postfix Changes HTML Formatting of CDO Email

Posted on 2014-02-14
Medium Priority
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
  • 6
  • 4

Author Comment

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

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 = "autopc@xyz.com"
obJMail.To = obJMail.To & "; abc@xyz-inc.com"
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=""https://www.abc.com?test="&rs("test")&""">"&rs("test")&"</a></td>"      
obJMail.HTMLBody = obJMail.HTMLBody & "</tr>"

set rs=nothing

set dbc=nothing

obJMail.HTMLBody = obJMail.HTMLBody & "</table>"
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

LVL 80

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 80

Accepted Solution

arnold earned 2000 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 80

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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
The main intent of this article is to make you aware of ‘Exchange fail to mount’ error, its effects, causes, and solution.
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

926 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