Hi,
I am trying to send a html email from a php script. This script emails
a common information to all the members in the database. The only
problem is I cannot specify colors, hyperlinks etc..Html tags like
<h1></h1>, <br/>, <b> etc works though..
Could any one tell me what i might be doing wrong? Any help will be
greatly appreciated.
Thanks,
Ann
Code:
function mail_it($conten t, $subject, $email, $recipient) {
global $attachment_chu nk, $attachment_nam e, $attachment_typ e,
$attachment_sen t, $bcc;
global $db;
global $msgbody;
$ob = "----=_OuterBoundary _000";
$ib = "----=_InnerBoundery _001";
$sql_result = mysql_query("SE LECT * FROM contacts", $db);
echo "<br/><b>Emails sent to:</b><br/>";
while($rs = mysql_fetch_arr ay($sql_result) )
{
$message = "";
$headers = "";
$recip = $rs["Email"];
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From: ".$email."\r\n" ;
$headers .= "To: ".$recip."\r\n" ;
$headers .= "Reply-To: ".$email."\r\n" ;
if ($bcc) $headers .= "Bcc: ".$bcc."\r\ n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-Mailer: Formmail".VERSI ON."\r\n";
$headers .= "Content-Type:
multipart/mixed;\r\n\tbou ndary=\"".$ob." \"\r\n";
$ToName = $rs["Salutation "]."".$rs["FirstName"]."
".$rs["LastName"];
$content = "Hello ".$ToName." ,<br/><br/>";
$content .= $msgbody;
$content .=" <br/><br/>";
$content .="Thank you.";
$content .=" <br/><br/><br/>";
$content .="<small><fo nt color='blue'>Pl ease send an email to <a
href='mailto:ab c@def.com&subje ct='Re:Email Notifications' to get more
information.</font></small>";
$message .= "This is a multi-part message in MIME format.\r\n";
$message .= "\r\n--".$ob."\r\n ";
$message .= "Content-Type:
multipart/alternative;\r\ n\tboundary=\"" .$ib."\"\r\n\r\ n";
$message .= "\r\n--".$ib."\r\n ";
//$message .= "Content-Type:
text/plain;\r\n\tcha rset=\"iso-8859-1\"\r\n";
$message .= "Content-Type:
text/html;\r\n\tchar set=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding:
quoted-printable\r\n\r \n";
$message .= $content."\r\n\ r\n";
$message .= "\r\n--".$ib."--\r\n";
if ($attachment_na me && !$attachment_se nt) {
$message .= "\r\n--".$ob."\r\n ";
$message .= "Content-Type:
$attachment_typ e;\r\n\tname=\" ".$attachment_n ame."\"\r\n";
$message .= "Content-Transfer-Encoding: base64\r\n";
$message .= "Content-Disposition:
attachment;\r\n \tfilename=\"". $attachment_nam e."\"\r\n\r\n ";
$message .= $attachment_chu nk;
$message .= "\r\n\r\n";
$attachment_sen t = 1;
}
$message .= "\r\n--".$ob."--\r\n";
mail($recip, $subject, $message, $headers);
}
}
I am trying to send a html email from a php script. This script emails
a common information to all the members in the database. The only
problem is I cannot specify colors, hyperlinks etc..Html tags like
<h1></h1>, <br/>, <b> etc works though..
Could any one tell me what i might be doing wrong? Any help will be
greatly appreciated.
Thanks,
Ann
Code:
function mail_it($conten t, $subject, $email, $recipient) {
global $attachment_chu nk, $attachment_nam e, $attachment_typ e,
$attachment_sen t, $bcc;
global $db;
global $msgbody;
$ob = "----=_OuterBoundary _000";
$ib = "----=_InnerBoundery _001";
$sql_result = mysql_query("SE LECT * FROM contacts", $db);
echo "<br/><b>Emails sent to:</b><br/>";
while($rs = mysql_fetch_arr ay($sql_result) )
{
$message = "";
$headers = "";
$recip = $rs["Email"];
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From: ".$email."\r\n" ;
$headers .= "To: ".$recip."\r\n" ;
$headers .= "Reply-To: ".$email."\r\n" ;
if ($bcc) $headers .= "Bcc: ".$bcc."\r\ n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-Mailer: Formmail".VERSI ON."\r\n";
$headers .= "Content-Type:
multipart/mixed;\r\n\tbou ndary=\"".$ob." \"\r\n";
$ToName = $rs["Salutation "]."".$rs["FirstName"]."
".$rs["LastName"];
$content = "Hello ".$ToName." ,<br/><br/>";
$content .= $msgbody;
$content .=" <br/><br/>";
$content .="Thank you.";
$content .=" <br/><br/><br/>";
$content .="<small><fo nt color='blue'>Pl ease send an email to <a
href='mailto:ab c@def.com&subje ct='Re:Email Notifications' to get more
information.</font></small>";
$message .= "This is a multi-part message in MIME format.\r\n";
$message .= "\r\n--".$ob."\r\n ";
$message .= "Content-Type:
multipart/alternative;\r\ n\tboundary=\"" .$ib."\"\r\n\r\ n";
$message .= "\r\n--".$ib."\r\n ";
//$message .= "Content-Type:
text/plain;\r\n\tcha rset=\"iso-8859-1\"\r\n";
$message .= "Content-Type:
text/html;\r\n\tchar set=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding:
quoted-printable\r\n\r \n";
$message .= $content."\r\n\ r\n";
$message .= "\r\n--".$ib."--\r\n";
if ($attachment_na me && !$attachment_se nt) {
$message .= "\r\n--".$ob."\r\n ";
$message .= "Content-Type:
$attachment_typ e;\r\n\tname=\" ".$attachment_n ame."\"\r\n";
$message .= "Content-Transfer-Encoding: base64\r\n";
$message .= "Content-Disposition:
attachment;\r\n \tfilename=\"". $attachment_nam e."\"\r\n\r\n ";
$message .= $attachment_chu nk;
$message .= "\r\n\r\n";
$attachment_sen t = 1;
}
$message .= "\r\n--".$ob."--\r\n";
mail($recip, $subject, $message, $headers);
}
}
Comment