0

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.

1
  • I highly suggest you to use a library like Swift or PHPMailer. Commented Jul 9, 2015 at 11:33

2 Answers 2

2

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/

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.