HTML emails not received correctly in Outlook

1,107 views
Skip to first unread message

D Gleba

unread,
Jul 16, 2013, 4:34:31 PM7/16/13
to xata...@googlegroups.com


I send the same email from Xataface using the php mail function to both a gmail address and a corporate address where the email is shown in outlook.

Randomly, the email is not correct in outlook. It is always correct in gmail. See screen shots where the same mail is incorrect in outlook, but OK in gmail.

We send about 30 mails a day, one at a time, not in a batch. Many days, there is an email with an error.

I realize this may not be a xataface issue, but I wonder if someone can help.

I don't see how the mail can be OK every time in gmail, but sometimes displayed incorrectly in outlook. I have read about outlook html mail challanges, but I think the code below is relatively simple.

Any ideas would be appreciated.


~=-=-=-=-=-=~
 
This shows a difference between the outlook and gmail.

outlook view source:

<td>generators: </td><t d=""><br>ESA not working properly #164387<br>925 gen...valve V6-1 doesn't function properly #161297<br>925 gen...V1 valve doesn't function properly #183216 and #228798<br></td>

gmail.

<td>generators: </td><td><br/>ESA not working properly #164387<br/>925 gen...valve V6-1 doesn't function properly #161297<br/>925 gen...V1 valve doesn't function properly #183216 and #228798<br/></td></tr>


~=-=-=-=-=-=~ 

outlook view source, the whole table:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body><table rules="all" border="1" style="border: 1px solid #211D57;" cellpadding="5"><tr style="background: #FEE5DF;"><td>Date reported: </td><td>2013-07-15</td></tr><tr style="background: #FEE5DF;"><td>Shift reported: </td><td>Days</td></tr><tr style="background: #FEE5DF;"><td>Reported by: </td><td>Cathy</td></tr><tr style="background: #FEE5DF;"><td>furnace_304: </td><td>RBO not functioning properly Work order #141797</td></tr><tr style="background: #FEE5DF;"><td>furnace_305: </td><td>RBO not functioning properly #141798</td></tr><tr style="background: #FEE5DF;"><td>furnace_314: </td><td>muffle is in bad shape #239836</td></tr><tr style="background: #FEE5DF;"><td>furnace_315: </td><td>Moisture coming out of top petcocks #189170<br>Air ducts for burners boxes don't blow air #189736<br></td></tr><tr style="background: #FEE5DF;"><td>furnace_316: </td><td>Moisture comes out of top petcock #189171</td></tr><tr style="background: #FEE5DF;"><td>generators: </td><t d=""><br>ESA not working properly #164387<br>925 gen...valve V6-1 doesn't function properly #161297<br>925 gen...V1 valve doesn't function properly #183216 and #228798<br></td></tr><tr style="background: #FEE5DF;"><td>miscellaneous: </td><td>#567 torque tester # 241075 not working properly</td></tr><tr style="background: #FEE5DF;"><td>createdtime: </td><td>2013-07-15 14:08:28</td></tr><tr style="background: #FEE5DF;"><td>updatedtime: </td><td>2013-07-15 14:08:05</td></tr><tr style="background: #FEE5DF;"><td>id-number: </td><td>36</td></tr></table></body></html>


~=-=-=-=-=-=~ 

gmail:

<html><body><table rules="all" border="1" style="border: 1px solid #211D57;" cellpadding="5"><tr style='background: #FEE5DF;'><td>Date reported: </td><td>2013-07-15</td></tr><tr style='background: #FEE5DF;'><td>Shift reported: </td><td>Days</td></tr><tr style='background: #FEE5DF;'><td>Reported by: </td><td>Cathy</td></tr><tr style='background: #FEE5DF;'><td>furnace_304: </td><td>RBO not functioning properly Work order #141797</td></tr><tr style='background: #FEE5DF;'><td>furnace_305: </td><td>RBO not functioning properly #141798</td></tr><tr style='background: #FEE5DF;'><td>furnace_314: </td><td>muffle is in bad shape #239836</td></tr><tr style='background: #FEE5DF;'><td>furnace_315: </td><td>Moisture coming out of top petcocks #189170<br/>Air ducts for burners boxes don't blow air #189736<br/></td></tr><tr style='background: #FEE5DF;'><td>furnace_316: </td><td>Moisture comes out of top petcock #189171</td></tr><tr style='background: #FEE5DF;'><td>generators: </td><td><br/>ESA not working properly #164387<br/>925 gen...valve V6-1 doesn't function properly #161297<br/>925 gen...V1 valve doesn't function properly #183216 and #228798<br/></td></tr><tr style='background: #FEE5DF;'><td>miscellaneous: </td><td>#567 torque tester # 241075 not working properly</td></tr><tr style='background: #FEE5DF;'><td>createdtime: </td><td>2013-07-15 14:08:28</td></tr><tr style='background: #FEE5DF;'><td>updatedtime: </td><td>2013-07-15 14:08:05</td></tr><tr style='background: #FEE5DF;'><td>id-number: </td><td>36</td></tr></table></body></html>

~=-=-=-=-=-=~ 

This is my code. This one appears in the "table".php 


    function after_action_new($params = array())
    {
        $record =& $params['record'];
        
        $to1      = 'd...@s.com';
        $subject1 = 'CSD1-Sinter Shift Report Record Submitted';
        
        $headers1 = "From: " . "rpt1" . "\r\n";
        $headers1 .= "bcc: " . "d...@gmail.com, " . "\r\n";
        $headers1 .= "Reply-To: " . "Do-not@reply" . "\r\n";
        $headers1 .= "MIME-Version: 1.0\r\n";
        $headers1 .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        
        $message1 = '<html><body>';
        $message1 .= '<table rules="all" border="1" style="border: 1px solid #211D57;" cellpadding="5">';

        $rrecord = df_get_record('sf_csd1_sinter', array(
            'sfid' => $record->val('sfid')
        ));
        
        $message1 .= "<tr style='background: #FEE5DF;'><td>Date reported: </td><td>" . $rrecord->strval('sfdate') . "</td></tr>";
        $message1 .= "<tr style='background: #FEE5DF;'><td>Shift reported: </td><td>" . $rrecord->strval('sfshift') . "</td></tr>";
        $message1 .= "<tr style='background: #FEE5DF;'><td>Reported by: </td><td>" . $rrecord->strval('reportedby') . "</td></tr>";
        
        $message1 .= "<tr style='background: #FEE5DF;'><td>furnace_304: </td><td>" . $rrecord->strval('furnace_304') . "</td></tr>";
        $message1 .= "<tr style='background: #FEE5DF;'><td>furnace_305: </td><td>" . $rrecord->strval('furnace_305') . "</td></tr>";
        $message1 .= "<tr style='background: #FEE5DF;'><td>furnace_314: </td><td>" . $rrecord->strval('furnace_314') . "</td></tr>";
        $message1 .= "<tr style='background: #FEE5DF;'><td>furnace_315: </td><td>" . $rrecord->strval('furnace_315') . "</td></tr>";
        $message1 .= "<tr style='background: #FEE5DF;'><td>furnace_316: </td><td>" . $rrecord->strval('furnace_316') . "</td></tr>";
        $message1 .= "<tr style='background: #FEE5DF;'><td>generators: </td><td>" . $rrecord->strval('generators') . "</td></tr>";
        $message1 .= "<tr style='background: #FEE5DF;'><td>miscellaneous: </td><td>" . $rrecord->strval('miscellaneous') . "</td></tr>";

        $message1 .= "<tr style='background: #FEE5DF;'><td>createdtime: </td><td>" . $rrecord->strval('createdtime') . "</td></tr>";
        $message1 .= "<tr style='background: #FEE5DF;'><td>updatedtime: </td><td>" . $rrecord->strval('updatedtime') . "</td></tr>";
        $message1 .= "<tr style='background: #FEE5DF;'><td>id-number: </td><td>" . $rrecord->strval('sfid') . "</td></tr>";
        
        $message1 .= "</table>";
        $message1 .= "</body></html>";
        
        // replace \r and \n with html br tags to preserve new lines in the html email...
        $body1 = isset($message1) ? preg_replace('#(\\r\\n|\\n|\\r)#', '<br/>', $message1) : false;

        if (mail($to1, $subject1, $body1, $headers1)) {
            echo '<br><br><h1><span style="background-color:#00ff00;">Your email has been sent.</span></h1><br>';
        } else {
            echo '<br><br /><h1><span style="background-color:#ff0000;">There was a problem sending the email. Please try again.</span></h1><br />';
        }
        echo '<br /><br /><br /><span style="font-size:16px;">Press the BACK button in your browser to go back.</span><br />';
         
    }


~=-=-=-=-=-=~ 
Message has been deleted

D Gleba

unread,
Jul 16, 2013, 4:42:10 PM7/16/13
to xata...@googlegroups.com
Forgot to add screenshots.
See attached.

correctly displayed 2013-07-16_085003.jpg
incorrectly displayed 2013-07-16_085030.jpg

Steve Hannah

unread,
Jul 16, 2013, 4:44:57 PM7/16/13
to D Gleba, xata...@googlegroups.com
So what is the problem with the Outlook version specifically?  It looks like all of the content is the same.  It's just using a different font (and the font isn't specified in your HTML content so each client is free to use whichever font it wants for rendering it).

Steve


On Tue, Jul 16, 2013 at 1:42 PM, D Gleba <dgl...@gmail.com> wrote:
Forgot to add screenshots.
See attached.




--
Steve Hannah
Web Lite Solutions Corp.

d gleba

unread,
Jul 16, 2013, 4:55:47 PM7/16/13
to Steve Hannah, xata...@googlegroups.com
Looking at the row called "generators", the content for that row should be in the second column as it is in the gmail screenshoot. This just one example of how the table is messed up in outlook. Sometimes the content is outside the table, at the top. Sometimes the content for a cell is not displayed in the outlook web app at all.

D Gleba

unread,
Jul 16, 2013, 5:05:01 PM7/16/13
to xata...@googlegroups.com, Steve Hannah, dgl...@gmail.com
Attached is a screenshot of one where a <td> tag is showing. There are lots of different odd ways it is not displayed correctly. Sometimes, it isn't possible to figure out what it is supposed to mean.
2013-07-16_170235.jpg

Steve Hannah

unread,
Jul 16, 2013, 5:17:27 PM7/16/13
to D Gleba, xata...@googlegroups.com
Ok.  So outlook is adding a space between "t" and "d" in the <td> tag
<t d="">

Perhaps you have a hidden character there that is causing some problems?  If your text editor has a "show invisibles" option this would allow you to see if that is the case.

It's also possible that outlook is chopping the line (try placing some new lines between some of the tags to see if this clears it up.

Steve

D Gleba

unread,
Jul 19, 2013, 1:57:01 PM7/19/13
to xata...@googlegroups.com, D Gleba
This one is a brain tickler.

Another piece of info is that the very same code is used to send emails from google docs forms.  The mails have never been messed up in outlook.

I am tired of this problem right now. I might take a break from it and come back later.

Steve Hannah

unread,
Jul 19, 2013, 2:00:05 PM7/19/13
to D Gleba, xata...@googlegroups.com
You should look at the raw message that Google docs form sends, from outlook, and compare it to the raw message received from your PHP form.

The solution will then present itself.

Steve

D Gleba

unread,
Jul 29, 2013, 10:00:58 AM7/29/13
to xata...@googlegroups.com, D Gleba
I added this to my php script that sends the email. It adds a new line after every row in the table. I added it after the php below that comment "replace \r and \n with html br tags"

        $body1 = preg_replace('#(</td></tr>)#', '</td></tr>'.PHP_EOL, $body1);

It may be to soon to tell yet if this fixed it since the problem is random, but this may have fixed it. 





On Tuesday, July 16, 2013 5:17:27 PM UTC-4, Steve Hannah wrote:

D Gleba

unread,
Aug 14, 2013, 1:06:44 PM8/14/13
to xata...@googlegroups.com, D Gleba
I attach to this post the actual files I am using.
Things are working OK now.

The actions.ini puts a 'send email' button on the details view page of a record.

The applicationdelegate.php file calls the .js file to put up an alert when the send email button pressed.
superv1_send_email.php
actions.ini
ApplicationDelegate.php
handler-superv1_send_email.js

D Gleba

unread,
Aug 27, 2013, 9:23:06 AM8/27/13
to xata...@googlegroups.com, D Gleba
To close this issue...

The problem where the html table is displayed incorrectly in Microsoft Outlook is solved. 
Reply all
Reply to author
Forward
0 new messages