php send mail problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • khng

    php send mail problem

    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);

  • Manuel Lemos

    #2
    Re: php send mail problem

    Hello,

    on 11/17/2005 12:46 AM khng said the following:[color=blue]
    > 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.......[/color]

    I think sendmail does that when the message body is not encoded
    properly. You need to encode the message body with quoted-printable
    encoding. You may want to try this MIME message class that can send your
    message body with UTF-8 characters encoding them as quoted printable:




    --

    Regards,
    Manuel Lemos

    Metastorage - Data object relational mapping layer generator
    ✅「官方网站」mk体育拥有各种免费又安全的资源,因为亚洲当中中国玩家人口基数的众多,mk体育创造了中国网络游戏的神话,全球首推免费在线点播体育直播。


    PHP Classes - Free ready to use OOP components written in PHP

    Comment

    • khng

      #3
      Re: php send mail problem

      Thank you for your ideal, finally I found the solution.

      I hop that this is useful for other.

      The injection of other symbol is due to the fact that the message is
      too long without any line break character.

      So inorder to kill that problem, I just add \r\n between every 50
      character but not inside html tag

      Comment

      Working...