473,396 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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_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,D escription";
$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>".htmlspecialch ars($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 <ma********@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);

Nov 22 '05 #1
2 1389
Hello,

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


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:

http://www.phpclasses.org/mimemessage
--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
Nov 22 '05 #2
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

Dec 2 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Steve Horrillo | last post by:
I can't figure out why this script won't insert the subject in the email and why can't I control the font and size being used? I'm not sure where to post this. Let me know where if this is OT. ...
6
by: DigitalRick | last post by:
I have been running CDONTS in my ASPpages to send emails to me sent from my guestbook. It had been working fine untill I upgraded to Server 2003 (I am also running Exchange 2003) all locally. I...
6
by: John J. Hughes II | last post by:
I have a service that needs to send e-mail alerts. I have been attempting to use the System.Net.Mail function from .NET but this seems to require the IIS be installed and running. Since some of...
3
by: Jens | last post by:
Hi I am writing a ASP.NET web application that must sent some e-mails. I get the exception “Could not access 'CDO.Message' object” when I call SmtpMail.Send. This only happens when I send...
1
by: Sophie | last post by:
Hi, I'm not very good in english so excuse me if I have difficulty to explain my problem. I want to send a mail with VB.net with this code : Option Strict On Public Class Form1 Inherits...
10
by: Dennis | last post by:
I am trying to send an e-mail using one of the examples I got on this group as follows: (both toemail and myemail are valid e-mail addreses. 'System.Web.Mail' (requires reference to...
2
by: Ryan | last post by:
Hi, I receive an access denied error (see below) when attempting to send an email with BodyFormat=MailFormat.Html from an asp.net page. Exactly the same code works fine in a console...
14
by: supz | last post by:
Hi, I use the standard code given below to send an email from an ASP.NET web form. The code executes fine but no Email is sent. All emails get queued in the Inetpub mail queue. I'm using my...
14
by: Professor Yonce | last post by:
I have made form for E-Mail. I have entered code but the Import system does not work. It has squiggly line underneath it showing it is not communicating. It Will not build. Public Class...
4
by: =?Utf-8?B?dHBhcmtzNjk=?= | last post by:
I have a web page that at the click of a button must send a bunch (1000+) emails. Each email is sent individually. I have the code working fine, using Mail Message classes and smtp and all that. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.