954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

html email

hi,
i written a code for sending html maIL.MAIL FUNCTION IS WORKING BUT THE MAIL I AM GETTING I HAVE DISPLAYED BELOW.please do tell me how to send html mail
$headers = "From: [email]cggroup@car.com[/email]";
$toa = "lydia@gmail.com";
$subject1 = "An Agreement has been signed for your Job Order";
$body2="<html><head></head><body>";
$body2.="<table width='850px' border='0' align='center' cellpadding='0' cellspacing='0' style='vertical-align:top;'>";

$body2.="<tr><td valign='top'><table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>";

$body2.="<tr><td colspan='100%' style='width:100%'>";

$body2.="
<table style='width:100%;' cellspacing='0' cellpadding='0'><tr><td class='bar' style='width:80%;'>&nbsp;Personal Details</td> Hi $ownername, ";

$body2.="<td class='bar' style='width:5%; text-align:right; font-style:italic;'></td><td style='width:1%'>&nbsp;</td></tr>";

$body2.="</table></td></tr><tr><td><table width='100%' border='0' align='left' > Hi $ownername, ";

$body2.="<tr><td height='124' colspan='2'><table width='100%' border='0'><tr>";

$body2.="<td width='6%'>&nbsp;</td><td width='25%' align='left'><span class='heading' style='width: 10%'>Name:</span></td>";
$body2.="<b>With Regards,</b><b>CG Group</b>";
$body2.="</body></html>";

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1" . "\r\n";
if (strlen($body2)>998) {
$headers .= "Content-Transfer-Encoding: base64;" . "\r\n";
$body2=rtrim(chunk_split(base64_encode($body2)));
$headers .= 'From: ' . $from . "\r\n" .'X-Mailer: PHP/' . phpversion();
}
$sent = mail($toa, $subject1, $body2, $headers)

OUTPUT:

PGh0bWw+PGhlYWQ+PC9oZWFkPjxib2R5Pjx0YWJsZSB3aWR0aD0nODUwcHgnIGJvcmRlcj0nMCcg YWxpZ249J2NlbnRlcicgY2VsbHBhZGRpbmc9JzAnIGNlbGxzcGFjaW5nPScwJyBzdHlsZT0ndmVy dGljYWwtYWxpZ246dG9wOyc+PGJyIC8+

lydia21
Junior Poster
183 posts since Nov 2007
Reputation Points: 19
Solved Threads: 5
 

:-/ This script is working fine for me! I get mails with html tags.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

this is my whole code
then wats wrong
just run this and see
<html>
<head></head>
<body>
<?
$headers = "From: [email]cggroup@car.com[/email]";
$toa = "lydia.whitin@gmail.com";
$subject1 = "An Agreement has been signed for your Job Order";
$body2="<html><head></head><body>";
$body2.="<table width='850px' border='0' align='center' cellpadding='0' cellspacing='0' style='vertical-align:top;'>";

$body2.="<tr><td valign='top'><table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>";

$body2.="<tr><td colspan='100%' style='width:100%'>";

$body2.="
<table style='width:100%;' cellspacing='0' cellpadding='0'><tr><td class='bar' style='width:80%;'>&nbsp;Personal Details</td> Hi $ownername, ";

$body2.="<td class='bar' style='width:5%; text-align:right; font-style:italic;'></td><td style='width:1%'>&nbsp;</td></tr>";

$body2.="</table></td></tr><tr><td><table width='100%' border='0' align='left' > Hi $ownername, ";

$body2.="<tr><td height='124' colspan='2'><table width='100%' border='0'><tr>";

$body2.="<td width='6%'>&nbsp;</td><td width='25%' align='left'><span class='heading' style='width: 10%'>Name:</span></td>";

$body2.="<td colspan='3' align='left'></td>";

$body2.="</tr><tr><td>&nbsp;</td><td align='left'><span class='heading' style='width: 10%'>Address1:</span></td>";

$body2.="<td colspan='3' align='left'> </td></tr><tr><td>&nbsp;</td>";

$body2.="<td align='left'><span class='heading' style='width: 10%'>Address2:</span></td>";

$body2.="<td colspan='3' align='left'> </td></tr><tr><td>&nbsp;</td>";

$body2.="<td align='left' nowrap='nowrap'><span class='heading' style='width: 10%'>Date of Birth:</span></td>";

$body2.="<td width='26%' align='left'> </td>";

$body2.="<td width='26%' align='left'> </td>";

$body2.="
<td width='7%' align='left'><span class='heading' style='width: 10%'>Age:</span></td>";

$body2.="
<td width='36%' align='left'> </td></tr><tr><td>&nbsp;</td>";

$body2.="
<td align='left'><span class='heading' style='width: 10%'>Location:</span></td><td colspan='3' align='left'>";

$body2.="</td>";

$body2.="</tr><tr><td>&nbsp;</td><td class='heading'>Sex:</td><td colspan='3'> </td></tr>";

$body2.="</table></td><td width='43%'><table width='93%' bgcolor='#eeeeee'><tr><td colspan='2' align='left' class='bar'>Contact Information</td>";

$body2.="</tr><tr><td width='31%' height='30px' align='left' nowrap='nowrap'><span class='heading' style='width: 10%'>Home Phone:</span></td>";

$body2.="<td width='69%' align='left'> </td></tr><tr>";

$body2.="<td height='23px' align='left'><span class='heading' style='width: 10%'>Mobile:</span></td>
<td align='left'> </td>
</tr><tr>";

$body2.="
<td height='24' align='left'><span class='heading' style='width: 10%'>Email:</span></td>
<td align='left'> </td>";

$body2.="</tr></table></td></tr></table></td></tr><tr>";

$body2.="<td><table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td colspan='100%' style='height:5 px;' /></tr>";

$body2.="</table></td></tr><tr><td colspan='100%' style='height: 10px;' /></tr><tr>";

$body2.="
<td colspan='100%' style='width:100%'><table width='863' border='0' cellpadding='0' cellspacing='0' style='width:100%;'>";

$body2.="<tr><td width='82%' class='bar' style='width:80%;'>&nbsp;Qualification Details</td>";

$body2.="<td width='12%' class='bar' style='width:5%; text-align:right; font-style:italic;'>&nbsp;</td><td width='6%' style='width:1%'>&nbsp;</td>";

$body2.="</tr></table></td></tr><tr>";

$body2.="
<td><table width='788' border='0' align='center' cellpadding='0' cellspacing='0' ><tr><td style='height: 3px;' /></tr>";

$body2.="<tr><td valign='top' class='input' style='vertical-align:text-top;'>";

$body2.="<table width='100%' align='center' cellpadding='0' cellspacing='0' class='profile_table' ><tr>";

$body2.="<td style='height:15 px;' /></tr><tr><td class='table_title'>Qualification</td><td class='table_title'>Inst. Name</td>";

$body2.="<br /<td class='table_title'>Start</td><td class='table_title'>End</td><td class='table_title'>Percentage</td></tr>";

$body2.="<tr><td align='center' colspan='100%' style='background-color: #05637C; width: 70%; height: 1px;' /></tr>br />";

$body2.="<tr><td colspan='100%' class='style2' style='width:100%; margin: 5; text-align:center;'>No Qualification added Yet</td>";

$body2.="</tr>";


$body2.="<tr bgcolor='#eeeeee'><b>
<td class='input'> </td></b>";

$body2.="
<td class='input'> </td>";

$body2.="
<td class='input'> </td>";

$body2.="<td class='input'> </td>";
$body2.="<td class='input'> </td></tr>";


$body2.="<tr><td colspan='100%' style='height: 3px;' /></tr></table></td></tr></table>";

$body2.="</td></tr><tr><td><table width='100%' border='0' cellspacing='0' cellpadding='0'>";

$body2.="<tr><td colspan='100%' style='height:5 px;' /></tr></table></td></tr>>";

$body2.="<tr><td colspan='100%' style='height: 10px;' /></tr><tr><td colspan='100%' style='width:100%'>";

$body2.="<table style='width:100%;' cellspacing='0' cellpadding='0'><tr>";

$body2.="
<td class='bar' style='width:80%;'>&nbsp;Professional Details</td>";

$body2.="<td class='bar' style='width:5%; text-align:right; font-style:italic;'>&nbsp;</td>";

$body2.="
<td style='width:1%'>&nbsp;</td></tr></table></td></tr><tr>";

$body2.="
<td><table width='92%' border='0' align='center' cellpadding='0' cellspacing='0'>";

$body2.="<tr><td colspan='100%' style='height:5 px;' /></tr><tr><td colspan='3'><table width='100%' align='center' cellpadding='0' cellspacing='0' >";

$body2.="<tr><td colspan='100%' style='height: 3px;' /></tr><tr><td style='vertical-align:text-top;' colspan='100%' class='input'>";

$body2.="<table width='98%' align='center' cellpadding='0' cellspacing='0' class='profile_table'>
<tr><td colspan='100%' style='height:15 px;' /></tr>";

$body2.="<tr><td class='table_title'>Job Title</td><td class='table_title'>Comp. Name</td><td class='table_title'>Start</td>";

$body2.="
<td class='table_title'>End</td><td class='table_title'>Comments</td></tr>";

$body2.="<tr><td align='center' colspan='100%' style='background-color: #05637C; width: 70%; height: 1px;' /></tr>";

$body2.="<tr><td colspan='100%' style='height: 3px;' /></tr>";

$body2.="
<tr><td colspan='100%' class='style2' style='width:100%; margin: 5; text-align:center;'>No Professional Details added Yet</td></tr>";

$body2.="<tr bgcolor='#eeeeee'>";

$body2.="<td class='input' ></td><td class='input'></td>";

$body2.="
<td class='input'></td>";

$body2.="<td class='input'></td><td class='input'></td>";

$body2.="</tr><tr><td colspan='100%' style='height: 3px;' /></tr></table></td></tr></table></td>";

$body2.="</tr></table></td></tr><tr><td colspan='100%' style='height: 10px;' /></tr><tr>";

$body2.="<td colspan='100%' style='width:100%'><table style='width:100%;' cellspacing='0' cellpadding='0'><tr>";

$body2.="<td class='bar' style='width:80%;'>&nbsp;Resume</td><td class='bar' style='width:5%; text-align:right; font-style:italic;'>&nbsp;</td>";

$body2.="<td style='width:1%'>&nbsp;</td></tr></table></td></tr><tr><td><table width='100%' border='0' cellspacing='0' cellpadding='0'>";

$body2.="<tr><td colspan='100%' style='height:5px;' /></tr><tr><td height='2px'>&nbsp;</td><td>&nbsp;</td>";

$body2.="</tr><tr><td width='16'>&nbsp;</td><td width='867' colspan='100%' valign='bottom' class='input'><table class='b'>";

$body2.="
<tr><td width='10'>&nbsp;</td><td width='813' align='left' class='resume'>";

$body2.="</td></tr></table></td></tr></table></td></tr><tr><td width='16'>&nbsp;</td></tr>";

$body2.="</table></td></tr></table></td></tr><tr><td><table width='877' border='0' align='center' cellpadding='0' cellspacing='0'>";

$body2.="
<tr><td><table width='877' cellpadding='0' cellspacing='0'><tr><td class='bar' style='width:80%;'>&nbsp;Employement Details</td>";

$body2.="<td class='bar' style='width:5%; text-align:right; font-style:italic;'>&nbsp;</td>
<td style='width:1%'>&nbsp;</td>";

$body2.="</tr></table></td></tr><tr><td height='37' colspan='5' style='width:100%;height:20px;'></td></tr>";

$body2.="<tr><td valign='top'><table width='765' border='0' align='center' cellpadding='0' cellspacing='0' style=' border: 1px dotted #0033FF;'>";

$body2.="<tr><td colspan='100%' width='100%' height='1px'>&nbsp;</td></tr><tr><td width='24%' class='style2' style='width: 30%'>&nbsp;&nbsp;Target Job Title</td>";

$body2.="<td width='64%' class='input' style='width: 80%; font-size:10px;'><? echo $lin[1]; ?></td></tr>";

$body2.="<tr><td colspan='100%' width='100%' height='1px'>&nbsp;</td></tr><tr><td class='style2' style='width: 30%'>&nbsp;&nbsp;Present Employer</td>";

$body2.="<td class='input' style='width: 80%; font-size:10px;'></td> </tr>";

$body2.="<tr><td colspan='100%' width='100%' height='1px'>&nbsp;</td></tr><tr><td class='style2' style='width: 30%'>&nbsp;&nbsp;Willing To Relocate</td>";

$body2.="
<td class='input' style='width: 70%; font-size:10px;'> </td>";

$body2.="
</tr><tr><td colspan='100%' width='100%' height='1px'>&nbsp;</td></tr>";

$body2.="

<tr><td class='style2' style='width: 30%'>&nbsp;&nbsp;Annual Salary</td>";

$body2.="
<td class='input' style='width: 70%; font-size:10px;'></td></tr>";

$body2.="
<tr><td colspan='100%' width='100%' height='1px'>&nbsp;</td></tr><tr><td class='style2'><strong>&nbsp;&nbsp;Target Location</strong></td>";

$body2.="<td >&nbsp;</td></tr> <tr><td colspan='100%' style='height: 3px;' /></tr><tr>";

$body2.="
<td class='style2' style='width: 30%'>&nbsp;&nbsp;State:</td> <td class='input' style='width: 70%; font-size:10px;'>";

$body2.="</td></tr><tr><td colspan='100%' style='height: 3px;'></td></tr>";

$body2.="<tr><td colspan='100%' width='100%' height='1px'>&nbsp;</td></tr>";

$body2.="
</table></td></tr><tr><td>&nbsp;</td></tr>";

$body2.="
<tr><td><table width='100%' border='0' cellpadding='0' cellspacing='0' >";

$body2.="</table></td></tr></table></td></tr>";

$body2.="</table>";

$body2.="<b>With Regards,</b><b>CG Group</b>";
$body2.="</body></html>";

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1" . "\r\n";
if (strlen($body2)>998) {
$headers .= "Content-Transfer-Encoding: base64;" . "\r\n";
$body2=rtrim(chunk_split(base64_encode($body2)));
$headers .= 'From: ' . $from . "\r\n" .'X-Mailer: PHP/' . phpversion();
}
$sent = mail($toa, $subject1, $body2, $headers)
?>
</body>
</html>

lydia21
Junior Poster
183 posts since Nov 2007
Reputation Points: 19
Solved Threads: 5
 

If you echo $body2, you will see an encoded string. That is because, you are using base64_encode for $body2.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

then plz tell how to do.now i am getting only the personal details and regards in the last line

lydia21
Junior Poster
183 posts since Nov 2007
Reputation Points: 19
Solved Threads: 5
 

when i execute the second code which i have send i am getting something like the below output

OUTPUT:

PGh0bWw+PGhlYWQ+PC9oZWFkPjxib2R5Pjx0YWJsZSB3aWR0aD0nODUwcHgnIGJvcmRlcj0nMCcg YWxpZ249J2NlbnRlcicgY2VsbHBhZGRpbmc9JzAnIGNlbGxzcGFjaW5nPScwJyBzdHlsZT0ndmVy dGljYWwtYWxpZ246dG9wOyc+PGJyIC8+

lydia21
Junior Poster
183 posts since Nov 2007
Reputation Points: 19
Solved Threads: 5
 

Hmm.. Comment out this line $body2=rtrim(chunk_split(base64_encode($body2))); for time being ! I am wondering why it is not working! I hope someone else has an answer :?:

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

Something of a side note, while most clients will let you send them html email, most will replace attributes if they have quotes (single or double) surrounding them. So if you want to send

$body2.="<table width='850px' border='0' align='center' cellpadding='0' cellspacing='0' style='vertical-align:top;'>";

you'll have to get rid of those single quotes:

$body2.="<table width=850px border=0 align=center cellpadding=0 cellspacing=0 style=vertical-align:top;>";

Otherwise, big boys like hotmail and gmail will replace everything inside your quotes with meaningless garbage. Also, most of them don't even use a doctype so you are probably better off using html. These are some things that I learned the hard way.

buddylee17
Practically a Master Poster
697 posts since Nov 2007
Reputation Points: 232
Solved Threads: 137
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You