Solved

Postfix Changes HTML Formatting of CDO Email

Posted on 2014-02-14
11
823 Views
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.
0
Comment
Question by:dzirkelb
  • 6
  • 4
11 Comments
 

Author Comment

by:dzirkelb
ID: 39859003
The email is generated from classic asp if that matters.
0
 
LVL 77

Expert Comment

by:arnold
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.
0
 

Author Comment

by:dzirkelb
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
      .Update
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>"
rs.moveNext
Loop

rs.close
set rs=nothing

dbc.close
set dbc=nothing

obJMail.HTMLBody = obJMail.HTMLBody & "</table>"
obJMail.Send
%>
0
 
LVL 77

Expert Comment

by:arnold
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>.
0
 

Author Comment

by:dzirkelb
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.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 77

Accepted Solution

by:
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.
0
 

Author Comment

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

&lt;
 td&gt;SOLDER ASSY. VALVE LINE SHUTOFF VACUUM PUMP ASSY.</td></tr></table>

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

<td>SOLDER ASSY. VALVE LINE SHUTOFF VACUUM PUMP ASSY.</td></tr></table>

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?
0
 
LVL 77

Expert Comment

by:arnold
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

<greeting>
mail from: <youremailaddress>
rcpt to: <youremailaddress
data
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.
0
 

Author Comment

by:dzirkelb
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.
0
 
LVL 13

Expert Comment

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

Author Closing Comment

by:dzirkelb
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Microsoft has released various new features which are capable of handling various tasks. One of these tasks is ‘Migration from pop3 to Exchange Server’. Pop3 data stores various data along mailboxes like contacts, tasks, etc. So, it becomes the need…
Email signatures have numerous marketing benefits. Here are 8 top reasons to turn your email signature into a marketing channel.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…

910 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now