4

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 
Dmytro Hutsuliak
  • 1,677
  • 4
  • 19
  • 34
CJAY
  • 6,055
  • 16
  • 52
  • 90
  • 2
    possible duplicate of [Add HTML formatting in phpmailer](http://stackoverflow.com/questions/13789989/add-html-formatting-in-phpmailer) – gabe3886 Sep 23 '15 at 07:58
  • The output needs to be sent AS html, Meaning you need to send some info along in the headers telling the e-mail reader or w.e it's called that the content is to be read as HTML – Epodax Sep 23 '15 at 07:58

4 Answers4

5

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

$to = 'bob@example.com';
$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);
2

You need to set the HTML content type in the email header

"Content-Type: text/html; charset=ISO-8859-1\r\n"

Your code doesnt indicate some standard email sending method that im aware of so i cant help with actual code

BobbyTables
  • 3,498
  • 1
  • 22
  • 28
2

If you are using PHP Mailer then add this line in your script

$mail->IsHTML(true);
Awais Tahir
  • 180
  • 1
  • 10
1

There's a really good answer about this in this stackoverflow question which covers general HTML formatting.

You pretty much either need to set the content type of the e-mail by doing:

Content-type: text/html; charset=iso-8859-1

or, if using PHP mailer, use the following to set the e-mail to be HTML:

$mail->IsHTML(true);

Community
  • 1
  • 1
gabe3886
  • 4,075
  • 3
  • 24
  • 31