Jump to content

I have had this problem before but it fixed itself...


gergy008

Recommended Posts

I'm having trouble with this emailing script. As you can see it clearly sets the contect typw to text/html but when you read the email it's not in HTML like intended :(

 

        $to=$email;
$subject='Activate your account.';
$message="
<html>
<head>
  <title>Activate your account that doesn't show in HTML damn it -.-</title>
</head>
<body>
  <p>Nothing here.</p>
</body>
</html>
";
// To send HTML mail, the Content-type header must be PROPERLY set
$headers  = 'MIME-Version: 1.0' . '\r\n';
$headers .= 'Content-type: text/html; charset=iso-8859-1' . '\r\n';
// Additional headers
$headers .= 'To: $fname <$email>' . '\r\n';
$headers .= 'From: **************' . '\r\n';
$headers .= 'Reply-To: ******************' . '\r\n';
$headers .= 'X-Mailer: PHP/' . phpversion();	
// Mail it
$mail=mail($to, $subject, $message, $headers);

 

Can someone help me solve why it's sending as plain text and not HTML this is getting annoying :(

 

Thanks in advance,

Link to comment
Share on other sites

i don't like messing with all those details of mime types, etc. i suggest that you use an existing email class to make things simpler. i use rmail. if you follow the example scripts included in the download, it is very easy to set HTML, add attachments, etc.

 

http://www.phpguru.org/downloads/Rmail/Rmail%20for%20PHP/

 

I understand that your question relates to HTML and not attachments, but rmail does a great job of making HTML emails simple whether you add attachments or not.

Link to comment
Share on other sites

The reason the OPs code doesn't work is probably that the EOL characters are enclosed in single quotes, not double quotes. This is causing the email headers to be invalid.

 

Do this instead:

<?php
        $to=$email;
$subject='Activate your account.';
$message="
<html>
<head>
  <title>Activate your account that doesn't show in HTML damn it -.-</title>
</head>
<body>
  <p>Nothing here.</p>
</body>
</html>
";
// To send HTML mail, the Content-type header must be PROPERLY set
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
// Additional headers
$headers .= "To: $fname <$email>\r\n";
$headers .= "From: **************\r\n";
$headers .= "Reply-To: ******************\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion();	
// Mail it
$mail=mail($to, $subject, $message, $headers);
?>

 

Ken

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.