Reputation: 678
i am trying to send e-mail with html code inside. i have following code;
$message ="<html><head><title></title></head><body>test</body></html>";
$rmail = $mail_email;
$subject = "subject";
$head = "MIME-Version: 1.0 ";
$head .= "Content-type: text/html; charset=utf8";
$head .= "Date: ".date("r")." ";
$mail_at=mail($rmail, $subject, $message, $head);
but, when i open the mail, mail content is,
<html><head><title></title></head><body>test</body></html>
it is just sending the string not compile the html code.
Upvotes: 2
Views: 114
Reputation: 7501
You need to add newlines in your header
$head = "MIME-Version: 1.0 \r\n";
$head .= "Content-type: text/html; charset=utf8 \r\n";
$head .= "Date: ".date("r")." \r\n";
Otherwise the Content-type
header is on the same line as MIME-version
which won't work
Mostly \r\n
works for me but I've seen some servers where it only works with \n
Upvotes: 5