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_arr ay($res);
$fusername = $row["UserName"];
$femail = $row["Email"];
$message= ERNST."<html><b ody>";
$message.= "Hi ".htmlspecialch ars($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='#79B1D 2'><th>FileID</th><th>Group</th><th>Client
Name</th><th>Client Code</th><th>Year
End</th><th>Type</th><th>Descript ion</th></tr>";
$i=0;
foreach ($fileid as $x) {
$cname="";$gnam e="";$cc="";$yr ="";$type="";$d es="";
$query = "SELECT
c.clientname,g. groupname,clien tcode,yearend,t ype,Description ";
$query .= " FROM Client c, f_group g, f_folderlist fl,f_file f";
$query .= " where fl.fileid='$x' and fl.fileid=f.fil eid and
fl.clientid=c.c lientid and c.grpid = g.gpid" ;
$res2 = send_sql($query );
$j=1;
while($row2 = mysql_fetch_arr ay($res2)) {
$cname .= $j . ": " .htmlspecialcha rs($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["Descriptio n"];
$j++;
}
$message.="<tr align='center'> <td>".htmlspeci alchars($x)."<t d
align='left'>". htmlspecialchar s($gname)."<td
align='left'>". $cname."<td>".h tmlspecialchars ($cc)."<td>".ht mlspecialchars( $yr)."<td>".htm lspecialchars($ type)."<td>".ht mlspecialchars( $des);
} //endforeach
$message.= "</table>";
$message.= "<br>";
$message.="<tab le width='100%'><t r><td>Your truly,<BR>Syste m
Administration/Operator<td align='right'>D ate:
".htmlspecialch ars(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,$heade rs);
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_arr ay($res);
$fusername = $row["UserName"];
$femail = $row["Email"];
$message= ERNST."<html><b ody>";
$message.= "Hi ".htmlspecialch ars($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='#79B1D 2'><th>FileID</th><th>Group</th><th>Client
Name</th><th>Client Code</th><th>Year
End</th><th>Type</th><th>Descript ion</th></tr>";
$i=0;
foreach ($fileid as $x) {
$cname="";$gnam e="";$cc="";$yr ="";$type="";$d es="";
$query = "SELECT
c.clientname,g. groupname,clien tcode,yearend,t ype,Description ";
$query .= " FROM Client c, f_group g, f_folderlist fl,f_file f";
$query .= " where fl.fileid='$x' and fl.fileid=f.fil eid and
fl.clientid=c.c lientid and c.grpid = g.gpid" ;
$res2 = send_sql($query );
$j=1;
while($row2 = mysql_fetch_arr ay($res2)) {
$cname .= $j . ": " .htmlspecialcha rs($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["Descriptio n"];
$j++;
}
$message.="<tr align='center'> <td>".htmlspeci alchars($x)."<t d
align='left'>". htmlspecialchar s($gname)."<td
align='left'>". $cname."<td>".h tmlspecialchars ($cc)."<td>".ht mlspecialchars( $yr)."<td>".htm lspecialchars($ type)."<td>".ht mlspecialchars( $des);
} //endforeach
$message.= "</table>";
$message.= "<br>";
$message.="<tab le width='100%'><t r><td>Your truly,<BR>Syste m
Administration/Operator<td align='right'>D ate:
".htmlspecialch ars(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,$heade rs);
Comment