You are here: sending HTML emails - the char ! breaks the HTML « PHP Language « IT news, forums, messages
sending HTML emails - the char ! breaks the HTML

Posted by Kevin Raleigh on 08/05/07 07:00

I am sending an HTML email via class.phpmail.php.
Everything is working great except that when I send this email
message to myself I find the char " ! " is being injected into the
message. I can read the source by saving the message and opening
it in Dreamweaver.

Now when I send this email the char " ! " is not being used as you know
the char is not part of HTML.
However when I read the source code of the sent email message
there is a specific number of chars that are sent "2040" before an
exclamation
point is injected into my HTML email at the end of the first string.

This char " ! " is not part of the HTML php mailer that I am sending out.
If I add or subtract chars from the phpmail the char " ! " moves accordingly
in the body of the email that I receive.
So what I have is one very long line of code that ends abruptly with a " ! "
exclamation point. This char is breaking the HTML code and it allows
HTML source code to be displayed because one of the tags is broken.

Here is the code. Look to the very last line of the code to see the
offending char:

<html><head></head><body bgcolor='#FFFFFF' LINK='#FFFFFF' VLINK='#FFFFFF'
ALINK='#FFFFFF'><table width='620' border='0' align='center' cellpadding='0'
cellspacing='0' bgcolor='#092F5E'><tr><td height='115' colspan='3'
valign='top'><img alt='banner' src='cid:my-attach1'/></td></tr><tr><td
valign='top' width='18%' height='150'><p>&nbsp;</p><div align='center'
style='color:#FFFFFF; font-family:Verdana; line-height: 1.3em; font-size:
11px;'><p>WEDNESDAYS<br />Keys Chapel<br /><strong>7:15PM<//strong><br
/><em>(before service)</em> <br />The Connection<br />6:45PM<br />In Room
123 <br />Next Door</p><p>SUNDAYS<br />&quot;On Course&quot;<br />Crystal
Room<br /><strong>9:15AM</strong></p><p><a
href='http://www.bethel.org/WNLBulletin.pdf'>Events<br />Bulletin<br
/></a></p><p>PASTOR<br />Art Gorman</p><p>PHONE<br />(408) 246-6790<br
/>x247</p><br/><br/><br/><br/><br/><br/></div></td><td width='62%'
valign='top' bgcolor='#FFFFFF'><table width='100%' align='center'
cellpadding='20'><tr><td width='81%' align='left'
valign='top'><p>&nbsp;</p>Make my joy complete by being of the same mind,
maintaining the same love, united in spirit, intent on one purpose.<div
align='right'><strong>Philippians 2:2</strong></div> </td><td width='19%'
align='left' valign='top'><img alt='PA and Wife' src='cid:my-attach'/>
</td></tr><tr><td colspan='2' align='left' valign='top'><p><strong>Hi: Jack
</strong></p><p>tsst</p></td></tr><tr><td colspan='2' align='left'
valign='top'>If you wish to be removed from 1Purpose mailing list please <a
href='mailto:1padmin@1purpose-bethel.org' style='color:blue;'>click
here</a>! Place remove me in the subject list. Then place your name and
email address in the body of the document<br/><div align='right'>Thank
You!</div></td></tr></table></td><td valign='top' width='20%'><p><span
style=A:link {color:#FFFFFF; font-size: 9px;
font-family:Verdana;}'><br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
href='http://www.1purpose-bethel.org'>Home</a><br/>&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;<a href='http://w!

NOTICE that the last character is an " ! "

Has anyone ever had this problem before?
Any suggestions on how to break the html code into multiple lines of code?
Any suggestions on how to research this problem?
Do you know of anything that states a maximum string length in an email
string?

your insights will be greatly appreciated
thank you
Kevin

I doubt you will be interested but here is the source code for the phpmail:
Just copy it into your favorite reader if you wish to validate my code.
They are just a series of string for the email part:

<?php require_once('sessionMan_cookiesCheck_DBconn.php'); ?>

<?php
require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->From = "1PAdmin@mysite.org";
$mail->FromName = "PA";
$mail->Host = "relay-hosting.securesever.net"; // SMTP servers
$mail->Port = 3535;
//$mail->Mailer = "smtp";

$query = ('SELECT fName, email, accessLevel FROM user where
accessLevel="user"')or die(mysql_error());
$result = MYSQL_QUERY($query);

while ($row = mysql_fetch_array ($result))
{
// HTML body

$myBody ="<html>";
$myBody .="<head>";
$myBody .="</head>";
$myBody .="<body bgcolor='#FFFFFF' LINK='#FFFFFF' VLINK='#FFFFFF'
ALINK='#FFFFFF'>";
$myBody .="<table width='620' border='0' align='center' cellpadding='0'
cellspacing='0' bgcolor='#092F5E'>";
$myBody .="<tr>";
$myBody .="<td height='115' colspan='3' valign='top'>";
$myBody .="<img alt='banner' src='cid:my-attach1'/>"; //banner.jpeg--banner
image here
$myBody .="</td>";
$myBody .="</tr>";
$myBody .="<tr>";
$myBody .="<td valign='top' width='18%' height='150'>";
$myBody .="<p>&nbsp;</p>";
$myBody .="<div align='center' style='color:#FFFFFF; font-family:Verdana;
line-height: 1.3em; font-size: 11px;'>";
$myBody .="<p>WEDNESDAYS<br />";
$myBody .="Keys Chapel<br />";
$myBody .="<strong>7:15PM<//strong><br />";
$myBody .="<em>(before service)</em> <br />";
$myBody .="The Connection<br />";
$myBody .="6:45PM<br />";
$myBody .="In Room 123 <br />";
$myBody .="Next Door";
$myBody .="</p>";
$myBody .="<p>SUNDAYS<br />";
$myBody .="&quot;On Course&quot;<br />";
$myBody .="Crystal Room<br />";
$myBody .="<strong>9:15AM</strong></p>";
$myBody .="<p><a href='http://www.bethel.org/WNLBulletin.pdf'>Events<br
/>";
$myBody .="Bulletin<br /></a>";
$myBody .="</p>";
$myBody .="<p>PASTOR<br />";
$myBody .="PA</p>";
$myBody .="<p>PHONE<br />";
$myBody .="(408) 246-6790<br />";
$myBody .="x247</p><br/><br/><br/><br/><br/><br/>";
$myBody .="</div>";
$myBody .="</td>";
$myBody .="<td width='62%' valign='top' bgcolor='#FFFFFF'>";
$myBody .="<table width='100%' align='center' cellpadding='20'>";
$myBody .="<tr>";
$myBody .="<td width='81%' align='left' valign='top'>";
$myBody .="<p>&nbsp;</p>Make my joy complete by being of the same mind,
maintaining the same love, united in spirit, intent on one purpose.";
$myBody .="<div align='right'><strong>Philippians 2:2</strong></div>
</td>";
$myBody .="<td width='19%' align='left' valign='top'>";
$myBody .="<img alt='PA and Wife' src='cid:my-attach'/> ";
//PaAndWife.jpeg--image of pastor art and kay
$myBody .="</td>";
$myBody .="</tr>";
$myBody .="<tr>";
$myBody .="<td colspan='2' align='left' valign='top'>";
$myName = $row['fName'];
$myName = trim("$myName", "'");
$myBody .="<p><strong>Hi: $myName </strong></p>";// insert user name here
$myBody .="<p>".$_POST['elm1']."</p>";
$myBody .="</td>";
$myBody .="</tr>";
$myBody .="<tr>";
$myBody .="<td colspan='2' align='left' valign='top'>";
$myBody .="If you wish to be removed from 1Purpose mailing list please ";
$myBody .="<a href='mailto:1padmin@1purpose-bethel.org'
style='color:blue;'>click here</a>! Place remove me in the subject list.
Then place your name and email address in the body of the document<br/><div
align='right'>Thank You!</div>";
$myBody .="</td>";
$myBody .="</tr>";
$myBody .="</table>";
$myBody .="</td>";
$myBody .="<td valign='top' width='20%'>";
$myBody .="<p><span style=A:link {color:#FFFFFF; font-size: 9px;
font-family:Verdana;}'>";
$myBody .="<br/><br/>";
$myBody .="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
href='http://www.1purpose-bethel.org'>Home</a><br/>";
$myBody .="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
href='http://www.bethel.org/'>Bethel</a><br/>";
$myBody .="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
href='http://www.singles.ag.org/'>AG-Singles</a><br/>";
$myBody .="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
href='http://www.bethel.org/Sermons.htm'>Sermons</a><br/>";
$myBody .="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
href='http://www.1purpose-bethel.org/newsBriefs.php'>News</a><br/>";
$myBody .="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
href='http://www.1purpose-bethel.org/personalGrowth.html'>Growth</a> <br/>";
$myBody .="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
href='http://www.1purpose-bethel.org/ministries.html'>Ministries</a><br/>";
$myBody .="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
href='http://bible.oneplace.com/'>Bible Tools</a><br/>";
$myBody .="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
href='http://www.1purpose-bethel.org/sportsFitness.php'>Fitness-Sports</a>";
$myBody .="<br/>";
$myBody .="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
href='http://www.1purpose-bethel.org/images/phpSlideshow/phpslideshow.php'>S
lideshows</a><br />";
$myBody .="</span></p>";
$myBody .="</td>";
$myBody .="</tr>";
$myBody .="</table>";
$myBody .="</body>";
$myBody .="</html>";

// Plain text body (for mail clients that cannot read HTML)
$text_body = $_POST['plainTextBody'];
$mail->WordWrap = 80;
$mail->Body = $myBody;
$mail->AltBody = $text_body;
$mail->AddAddress(trim($row["email"], "'"), trim($row["fName"], "'"));
$mail->AddEmbeddedImage("banner.jpg", "my-attach1", "banner.jpg");
$mail->AddEmbeddedImage("PaAndWife.jpeg", "my-attach", "PaAndWife.jpeg");


//$mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");

if(!$mail->Send())
echo "There has been a mail error sending to " . $row["email"] .
"<br>";

// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}
?>
<script type="text/javascript">
alert("Your messages have been sent!\n\nMay the lord continue to bless this
ministry!\n\n");
window.location = "../connect.php";
</script>

<?php
echo "<h4>The mail has been sent! May the lord continue to bless this
ministry!</h4>";
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация