0

I'm using PHP to generate a fancy HTML email to send to visitors, but for some reason certain visitors are saying the HTML isn't working for them (seeing RAW HTML rather than pretty email).

I haven't narrowed it down to a certain client, but having talked to them they say they can receive other HTML emails so it's something I'm doing wrong...

My PHP code is as follows

$to = 'jm391@le.ac.uk';
$subject = 'Daily Update - New Bikes Matching Your Alerts';
$headers = "From: john@findthatbike.co.uk\r\n";
$headers .= "Reply-To: john@findthatbike.co.uk\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";


if (mail($to, $subject, $message, $headers)) {
    echo 'Your message has been sent<br/>';
} else {
    echo 'There was a problem sending the email.<br/>';
}

And my $message variable is loaded with the below links HTML source

http://www.findthatbike.co.uk/sampleemail.html

My customer forwarded a non working email to me and the forwarded chunk look like the below, I'm told he gets HTML emails from others so really not sure what to try...

From: john@findthatbike.co.uk [mailto:john@findthatbike.co.uk] 
Sent: 05 April 2013 08:35
To: XXXXX XXXXX
Subject: Daily Update - New Bikes Matching Your Alerts

Reply-To: john@findthatbike.co.uk

MIME-Version: 1.0

Content-Type: text/html; charset=ISO-8859-1
Message-Id: <20130405073022.8597D9CF79D@MY SERVER ADDRESS>
Date: Fri,  5 Apr 2013 08:30:22 +0100 (BST)
X-invURIBL-Scan: Scanned by invURIBL 3.1.1 on 05/04/2013 08:34:17
X-invURIBL-Weight: 0
X-invURIBL-Range: CLEAN
X-Declude-Sender: MY SERVER NAME [MY SERVER IP]
X-Declude-Spoolname: 72086847.eml
X-Declude-RefID: 
X-MessageStream-Note: Scanned by MessageStream (www.messagestream.com).
X-MessageStream-Scan: Score [0] at 08:34:29 on 05 Apr 2013
X-MessageStream-Tests: Whitelisted
X-Country-Chain: UNITED KINGDOM->destination


        <html>
        <body style="background:url('http://findthatbike.co.uk/images/bg3.jpg') repeat fixed 0 0 #EEEEEE; padding-top: 10px; padding-bottom: 10px;">
x41x41x41
  • 113
  • 1
  • 1
  • 8
  • What's the error they are getting? or which part isn't working? Sometimes if the sender is not in the safe list certain things like links, images...etc doesn't show up in emails... – Jay Bhatt Apr 05 '13 at 11:42
  • Sorry should of been clearer they are simply seeing the raw code not a nice pretty HTML email. I've added that, and also a copy the forwarded email the custoemr gave me... – x41x41x41 Apr 05 '13 at 11:47
  • Notice the double line breaks between your headers. A quick search leads to http://stackoverflow.com/questions/3449431/ and some related links. – DCoder Apr 05 '13 at 11:52
  • with which email client this issue occurs? I.e. Hotmail has a view source option which allows clients to see raw html output instead of html... – Jay Bhatt Apr 05 '13 at 11:55
  • Thanks solved it, I also noticed many people saying the PHP mail function isn't good and to use phpmailer class instead so I moved over to that and it works without any messing around with headers. – x41x41x41 Apr 05 '13 at 15:47

0 Answers0