|
Posted by khng on 11/17/05 04:46
Current, I have a function to send UTF-8 encoded HTML Format email to
user.
But my found that the produced email sometime accidently being injected
with the ! sign.......
e.g. <td> sometime become <!td>
here is the code for that function
$sql = "select * from user where userid='$userid'";
$res = send_sql($sql);
//Get Reserve staff info
$row = mysql_fetch_array($res);
$fusername = $row["UserName"];
$femail = $row["Email"];
$message= ERNST."<html><body>";
$message.= "Hi ".htmlspecialchars($fusername).",<br><br>";
$message.= "Please note that the system accepted your borrowing of
files at ".date("d M Y H:i:s")."<br>";
$message.= "<br>";
$message.= "<table width='100%' border='1'>";
$message.= "<tr align='center'
bgcolor='#79B1D2'><th>FileID</th><th>Group</th><th>Client
Name</th><th>Client Code</th><th>Year
End</th><th>Type</th><th>Description</th></tr>";
$i=0;
foreach ($fileid as $x) {
$cname="";$gname="";$cc="";$yr="";$type="";$des="";
$query = "SELECT
c.clientname,g.groupname,clientcode,yearend,type,Description";
$query .= " FROM Client c, f_group g, f_folderlist fl,f_file f";
$query .= " where fl.fileid='$x' and fl.fileid=f.fileid and
fl.clientid=c.clientid and c.grpid = g.gpid" ;
$res2 = send_sql($query);
$j=1;
while($row2 = mysql_fetch_array($res2)) {
$cname .= $j . ": " .htmlspecialchars($row2["clientname"]);
if ($j<=mysql_num_rows($res2)-1) $cname.="<br>";
$gname = $row2["groupname"];
$cc=$row2["clientcode"];
$type=$row2["type"];
$yr=$row2["yearend"];
$des=$row2["Description"];
$j++;
}
$message.="<tr align='center'><td>".htmlspecialchars($x)."<td
align='left'>".htmlspecialchars($gname)."<td
align='left'>".$cname."<td>".htmlspecialchars($cc)."<td>".htmlspecialchars($yr)."<td>".htmlspecialchars($type)."<td>".htmlspecialchars($des);
} //endforeach
$message.= "</table>";
$message.= "<br>";
$message.="<table width='100%'><tr><td>Your truly,<BR>System
Administration/Operator<td align='right'>Date:
".htmlspecialchars(date("d M Y"))."</table>";
$message.= "</body></html>";
$headers ="From: MailDaemon <maildaemon@hk.ey.com>\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: text/html; charset=utf-8\r\n" .
"Content-Transfer-Encoding: 8bit\r\n\r\n";
@mail($femail, "Notify of File borrowing", $message,$headers);
[Back to original message]
|