0

Is it possible to use HTML tags in PHP code? I have a php script that emails some form inputs to my email address, and I would like to bold certain words in it. The code preforms the message first, and then just posts the message in the body of the email like this:

$body = "Date Submitted: $today\n Client: $client\n From: $requestor\n $services";

I would like to make some words bold. Like the word Client. In that body message, how can I make it come up bold in the email?
Thanks.

3
Contributors
9
Replies
13
Views
11 Years
Discussion Span
Last Post by nathanpacker
0

Use the content-type:text/html instead of content-type:text/plain header when sending off the email.

0

Use the content-type:text/html instead of content-type:text/plain header when sending off the email.

Thanks cscgal. Kudos to you for being so involved in your forum. I swear you answer almost every post, and I don't know how you do it!

But if I may bother you once more, where do I include this content-type:text/plain? At the heading of the php script or something? I wrote the script by hand, so it's very unformal, and probably not really legit.

Thanks again!
Nate

0

Within the headers parameter of the mail() function used to actually send out the email.

For example, here is an example off of php.net:

<?php
// multiple recipients
$to  = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';
 
// subject
$subject = 'Birthday Reminders for August';
 
// message
$message = '
<html>
<head>
  <title>Birthday Reminders for August</title>
</head>
<body>
  <p>Here are the birthdays upcoming in August!</p>
  <table>
   <tr>
     <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
   </tr>
   <tr>
     <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
   </tr>
   <tr>
     <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
   </tr>
  </table>
</body>
</html>
';
 
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
 
// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
 
// Mail it
mail($to, $subject, $message, $headers);
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.