[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 926
  • 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.
0
dzirkelb
Asked:
dzirkelb
  • 6
  • 4
1 Solution
 
dzirkelbAuthor Commented:
The email is generated from classic asp if that matters.
0
 
arnoldCommented:
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
 
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
      .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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
arnoldCommented:
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
 
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.
0
 
arnoldCommented:
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
 
dzirkelbAuthor Commented:
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
 
arnoldCommented:
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
 
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.
0
 
SandyCommented:
Check you might be using SMTP over SSL.
0
 
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.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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