Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending HTML vs Text through mail function

Status
Not open for further replies.

sd0t1

IS-IT--Management
Mar 14, 2007
131
US
can anyone tell me why when I email from the mail function the user gets text and not HTML.

here is the code.

$subject = "You have overtime requests to approve.";

$message =
"<table width='736' height='509' border='1' cellpadding='0' cellspacing='0' bordercolor='#000000' bgcolor='#26354A'>
<tr>
<th colspan='2' scope='col'><table width='100%' height='509' border='0' cellpadding='0' cellspacing='0' bgcolor='#D3DCE6'>
<tr>
<th width='230' rowspan='2' align='left' valign='top' bgcolor='#26354A' scope='col'><img src='images/birch.JPG' width='230' height='286' /></th>
<th width='500' height='19' scope='col'>&nbsp;</th>
</tr>
<tr>
<td height='176' align='left' valign='top'><blockquote>
<p class='style1'>You have a message. </p>
<p class='style1'>Please login to view your requests.</p>
<p class='style2'><a href='login.php'>Click Here to Login </a></p>
</blockquote> </td>
</tr>
<tr>
<th bgcolor='#26354A' scope='row'>&nbsp;</th>
<td>&nbsp;</td>
</tr>
</table></th>
</tr>
</table>";


$to = $row_mgr_email['email'];

mail($to, $subject, $message);

and this is what I get in the email.

<table width='736' height='509' border='1' cellpadding='0' cellspacing='0' bordercolor='#000000' bgcolor='#26354A'>
<tr>
<th colspan='2' scope='col'><table width='100%' height='509' border='0' cellpadding='0' cellspacing='0' bgcolor='#D3DCE6'>
<tr>
<th width='230' rowspan='2' align='left' valign='top' bgcolor='#26354A' scope='col'><img src='images/birch.JPG' width='230' height='286' /></th>
<th width='500' height='19' scope='col'>&nbsp;</th>
</tr>
<tr>
<td height='176' align='left' valign='top'><blockquote>
<p class='style1'>You have a message. </p>
<p class='style1'>Please login to view your requests.</p>
<p class='style2'><a href='login.php'>Click Here to Login </a></p>
</blockquote> </td>
</tr>
<tr>
<th bgcolor='#26354A' scope='row'>&nbsp;</th>
<td>&nbsp;</td>
</tr>
</table></th>
</tr>
</table>

Thanks.
 
HTML mail must be sent as MIME email. Only text can be sent via a plain email.

When I need to do in PHP anything more complicated than sending text messages, I use PHPMailer



Want the best answers? Ask the best questions! TANSTAAFL!
 
Some hosting outfits block mailer classes that are out of date or considered vulnerable to spammers. Its happened to me a few times over the years.

Also you should consider some rigorous validation before actually sending the email. Spammers are quite creative in hijacking web forms. This thread is worth reading:

-Pete
Games the old fashion way with Dice, Paper and Pencils!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top