Reputation: 125
I am trying to send an email with a link, the problem im facing is that outlook does not reconize the HTML which is being put in the email.
$onderwerp = "test";
$bericht = <<<EOT
<html>
<head>
<title>Email_test</title>
</head>
<body>
<a href="http://www.link.com/index.php?page=members&id={$last_insert_id}">* the link</a>
</body>
</html>
EOT;
$headers = 'From: ' . $verstuurd_van;
mail($naar_1, $onderwerp, $bericht, $headers);
Thanks in forehand for the help.
Upvotes: 0
Views: 349
Reputation: 5166
just mention the headers in your email script like .
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
so your script will
$onderwerp = "test";
$bericht = <<<EOT
<html>
<head>
<title>Email_test</title>
</head>
<body>
<a href="http://www.link.com/index.php?page=members&id={$last_insert_id}">* the link</a>
</body>
</html>
EOT;
$headers = 'From: ' . $verstuurd_van;
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
mail($naar_1, $onderwerp, $bericht, $headers);
you can take reference from html email with php or w3school email html
Upvotes: 0
Reputation: 7661
In order to be able to send a HTML email you need to add a few more headers:
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
So the entire email becomes something like:
$to = '[email protected]';
$subject = 'Test';
$message = "
<html>
<body>
<p>
Hallo <b>Example</b>,
</p>
</body>
</html>";
$headers = "From: [email protected]\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to, $subject, $message, $headers);
Also take a look at: https://css-tricks.com/sending-nice-html-email-with-php/
Upvotes: 2