Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Php how to send mail with bold text

Tags:

php

Here I am trying to send the email with some text highlighted in bold. Here is what I have tried but I am getting the tags as it is but I am not getting the bold font. How can I do this?

Here is what I have done:

$mail->Body = PROPOSE_STATEMENT." <b>".$product_name."</b> ".REJECTED;

Here I have used the html <b></b> tags in the php to make the text bold but I am getting output like this:

 you proposed <b>TVS Apache RTR 160</b> Has been 
like image 970
CJAY Avatar asked Dec 25 '22 14:12

CJAY


1 Answers

You have to send an HTML Mail. Set to, subject and headers (Set HTML in header)

$to = '[email protected]';
$subject = 'Request'; 
$headers .= "MIME-Version: 1.0\r\n";
//Set the content-type to html
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

Now you can use HTML

$message = '<html><body>';
$message .= '<h1>Hello, World!</h1><b>bold</b>';
$message .= '</body></html>';

And send the Mail

mail($to, $subject, $message, $headers);
like image 116
Haselnussstrauch Avatar answered Jan 02 '23 13:01

Haselnussstrauch