0

I have tried to send an email from PHP with the next body:

$message .= 'This is a simple message';
$message .= "\n";
$message .= 'http://www.yahoo.com';
$message .= "\n";
$message .= "<a href='https://www.google.com'>Google</a>";
$message .= "\n";

As a result I got the next output:

This is a simple message    //This line is ok
http://www.yahoo.com        //This line is ok
<a href='https://www.google.com'>Google</a> //It should appear the word Google clickable but it does not

Instead of having the word Google with the link clickable to the Google site I get the html code, how could I fix this? Thanks

myString
  • 11
  • 1

2 Answers2

0

I'm not sure, haven't tried it but maybe try:

$message .= '<a href="https://www.google.com">Google</a>';

NOTE: added double quotes in href link

4u2c
  • 88
  • 1
  • 11
0

You need to be sure you're sending mail as HTML and not as text/plain that is probably in your case so you get HTML as source code and not as it should look 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";

more read here:

Jimmix
  • 5,644
  • 6
  • 44
  • 71