Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 942
  • Last Modified:

Postfix Changes HTML Formatting of CDO Email

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.
  • 6
  • 4
1 Solution
dzirkelbAuthor Commented:
The email is generated from classic asp if that matters.
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.
dzirkelbAuthor Commented:
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>"
Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

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>.
dzirkelbAuthor Commented:
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.
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.
dzirkelbAuthor Commented:
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?
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.
dzirkelbAuthor Commented:
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.
Check you might be using SMTP over SSL.
dzirkelbAuthor Commented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now