emachine emachine - 3 months ago 10
HTML Question

PHP HTML email sent showing code

I have a website that's sending out confirmation emails. When I send an email directly to my gmail account or work account it shows up as expected, however, when it goes through another email address registered through godaddy or one through Network Solutions it shows up like this:

Reply-To: tom@yahoo.com

Content-Type: text/html; boundary="PHP-alt-cabc44cdb6c49a722d25637d7407d89c"
Message-Id: <20121024134543.9B59E10076@server1.serverdomain.com>
Date: Wed, 24 Oct 2012 08:45:43 -0500 (CDT)

<html><body><h1>You have been registered for Future Event</h1><div><b>Date:</b> March 4th, 2013</div><div><b>Time:</b> 12:00am</div><div><p>Come one come all. Step into the future</p></div><div><a href="http://example.com/create_ical/?m=6ea267734713bd10" target="_blank">Download to your calendar</a></div><a href="http://www.example.com/adtracking/?a=532ff9c94b851df4&l=http://www.example.com/?x=ad" target="_blank" style="border-width:0px; margin-left:auto; margin-right:auto; display:block; margin-top:20px;"><img src="http://www.example.com/i/ads/57db2ce3d22e4636_ad_mrc_300_250.jpg" style="border-width:0px; margin-left:auto; margin-right:auto; display:block; margin-top:20px;"></a></body></html>


Godaddy basically said it's my fault and they're not responsible.

This is how I set up my headers:

$_HEADERS = "From: " . $_HOST["email"] . "\r\nReply-To: " . $_HOST["email"] . "";
$_HEADERS .= "\r\nContent-Type: text/html; boundary=\"PHP-alt-".$_random_hash."\"";


This is the full email:

Delivered-To: through-godaddy-to-my-account-at@gmail.com
Received: by 10.58.227.40 with SMTP id rx8csp526380vec;
Wed, 24 Oct 2012 06:46:02 -0700 (PDT)
Received: by 10.52.90.212 with SMTP id by20mr22114953vdb.118.1351086361703;
Wed, 24 Oct 2012 06:46:01 -0700 (PDT)
Received-SPF: pass (google.com: best guess record for domain of server1.serverdomain.com designates 66.18.17.26 as permitted sender) client-ip=66.18.17.26;
Message-ID: <5087f119.9bcfdc0a.6321.234eMFETCHER_ADDED@google.com>
Received: by 10.220.207.155 with POP3 id fy27mf482750vcb.7;
Wed, 24 Oct 2012 06:46:01 -0700 (PDT)
X-Gmail-Fetch-Info: email-at-godaddy@example.com 1 pop.secureserver.net 110 email-at-godaddy@example.com
Received: (qmail 13064 invoked by uid 30297); 24 Oct 2012 13:45:46 -0000
Received: from unknown (HELO m1pismtp01-016.prod.mesa1.secureserver.net) ([10.8.12.16])
(envelope-sender <apache@server1.serverdomain.com>)
by p3plsmtp14-04.prod.phx3.secureserver.net (qmail-1.03) with SMTP
for <email-at-godaddy@example.com>; 24 Oct 2012 13:45:46 -0000
X-IronPort-Anti-Spam-Result: ApIxAH/wh1BCEhEa/2dsb2JhbABEghiJdKNaMQEBkGdwgQiCGoEzID4ZASqFSQeCGAkBAw8LmXGPHId3ASOVAmeDSYIegQYDlCKCaIQihXCFEA
Received: from server1.serverdomain.com ([66.18.17.26])
by m1pismtp01-016.prod.mesa1.secureserver.net with ESMTP; 24 Oct 2012 06:45:45 -0700
Received: by server1.serverdomain.com (Postfix, from userid 48)
id 9B59E10076; Wed, 24 Oct 2012 08:45:43 -0500 (CDT)
To: email-at-godaddy@example.com
Subject: You have successfully registered for Future Event
From: tom@yahoo.com
X-Nonspam: None
Date: Wed, 24 Oct 2012 06:46:01 -0700 (PDT)

Reply-To: tom@yahoo.com

Content-Type: text/html; boundary="PHP-alt-cabc44cdb6c49a722d25637d7407d89c"
Message-Id: <20121024134543.9B59E10076@server1.serverdomain.com.com>
Date: Wed, 24 Oct 2012 08:45:43 -0500 (CDT)

<html><body><h1>You have been registered for Future Event</h1><div><b>Date:</b> March 4th, 2013</div><div><b>Time:</b> 12:00am</div><div><p>Come one come all. Step into the future</p></div><div><a href="http://example.com/create_ical/?m=6ea267734713bd10" target="_blank">Download to your calendar</a></div><a href="http://www.example.com/adtracking/?a=532ff9c94b851df4&l=http://www.example.com/?x=ad" target="_blank" style="border-width:0px; margin-left:auto; margin-right:auto; display:block; margin-top:20px;"><img src="http://www.example.com/i/ads/57db2ce3d22e4636_ad_mrc_300_250.jpg" style="border-width:0px; margin-left:auto; margin-right:auto; display:block; margin-top:20px;"></a></body></html>

Answer

You should only use 'boundary' if you're sending multipart messages. Probably this confuses GoDaddy's parsers, or spam-checkers, or whatever; they unpack your mail and repack it so it looks "wrong".

Yet it's not really GoDaddy's fault if they're not so "liberal in what they accept" as Google is.

Look into a class such as PHPMailer, or multipart structure; or send just HTML without boundaries (see e.g. http://www.w3schools.com/php/func_mail_mail.asp ).

Update

Comparing your headers with another HTML mail, some differences appear:

From: tom@yahoo.com
X-Nonspam: None
Date: Wed, 24 Oct 2012 06:46:01 -0700 (PDT)

Reply-To: tom@yahoo.com

Content-Type: text/html; boundary="PHP-alt-cabc44cdb6c49a722d25637d7407d89c"
Message-Id: <20121024134543.9B59E10076@server1.serverdomain.com.com>
Date: Wed, 24 Oct 2012 08:45:43 -0500 (CDT)


From: <redacted>
To: <redacted>
Date: Mon, 04 Apr 2011 10:33:32 +0200
MIME-Version: 1.0
Content-Type: text/html; charset="ISO-8859-15"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

Specifically, those empty lines around "Reply-To:" might make the system believe the headers are terminated and what follows is the email text content. This may be caused by an incorrect line terminator character when assembling headers.