HTML email just shows as Code
13,612
Solution 1
from the docs: http://php.net/manual/en/function.mail.php
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
obviously $headers has to be passed to the mail
Solution 2
here you go:
// multiple recipients
$to = '[email protected]';
//subject
$subject = 'Email Template for Lazy People';
//message body
$message = "
<html>
<head>
<title>My Title</title>
</head>
<body>
<div>
<b>My email body</b>
</div>
</body>
</html>
";
//add headers
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: yourself<[email protected]>' . "\r\n";
$headers .= 'From: myself<[email protected]>' . "\r\n";
//send mail
mail($to, $subject, $message, $headers);
Author by
Philip Kirkbride
Updated on June 28, 2022Comments
-
Philip Kirkbride almost 2 years
Possible Duplicate:
Sending HTML email from PHPUsing PHP to send an email.
I want it to be HTML based but when I get the email in my inbox it just shows the raw code.
How can I make it interprited as HTML rather then just text?!
For everyone asking to see the code
<?php //The email of the sender $email = $_POST['email']; //The message of the sender $message = "<html></html>"; //The subject of the email $subject = "Fanshawe Student Success"; $extra = $email."\r\nReply-To: ".$email."\r\n"; mail($email,$subject,$message,$extra); ?>
-
Griwes almost 13 yearsI think the problem is much deeper :D
-
Philip Kirkbride almost 13 yearsThanks all, Our Prof. never went over headers when we went over mailscripts so it was not so obvious for me. But greatly Appreciated!
-
mutiemule about 10 yearsThis helped me. Thank you