|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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> </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 />"On Course"<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> </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/> <a href='http://www.1purpose-bethel.org'>Home</a><br/> & 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_Check_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> </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 .=""On Course"<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> </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 .=" <a href='http://www.1purpose-bethel.org'>Home</a><br/>"; $myBody .=" <a href='http://www.bethel.org/'>Bethel</a><br/>"; $myBody .=" <a href='http://www.singles.ag.org/'>AG-Singles</a><br/>"; $myBody .=" <a href='http://www.bethel.org/Sermons.htm'>Sermons</a><br/>"; $myBody .=" <a href='http://www.1purpose-bethel.org/newsBriefs.php'>News</a><br/>"; $myBody .=" <a href='http://www.1purpose-bethel.org/personalGrowth.html'>Growth</a> <br/>"; $myBody .=" <a href='http://www.1purpose-bethel.org/ministries.html'>Ministries</a><br/>"; $myBody .=" <a href='http://bible.oneplace.com/'>Bible Tools</a><br/>"; $myBody .=" <a href='http://www.1purpose-bethel.org/sportsFitness.php'>Fitness-Sports</a>"; $myBody .="<br/>"; $myBody .=" <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>"; ?> |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Kevin Raleigh wrote:
[snip] > > NOTICE that the last character is an " ! " > > Has anyone ever had this problem before? No. And I can't reproduce it. I sent this same email to myself and it worked fine. > Any suggestions on how to break the html code into multiple lines of code? Yes. You put a new line character at the end of each line. eg., $line = "Stuff\n"; // ^^--- the \n is the "new line" character Or, you can quote the whole thing.. no need to keep appending the $myBody var with .= , but since you have double and single quotes in the HTML, you should use a HERE document... see my rewrite below. I took the liberty of cleaning up your HTML using the very cool "HTML Tidy" interface at http://infohound.net/tidy/ I tried it myself, and no ! at the end. Here is a rewrite of your code (just the while loop) with $myBody quoted in a HERE document. Without seeing what is in $_POST['elm1'], I can't be sure that that isn't the problem. Hope this s. Matt M. ------------------------------------------------------------------- while ($row = mysql_fetch_array ($result)) { $myName = trim($row['fName'], "'"); $elm1 = $_POST['elm1']; $myBody = <<<HERE <html> <head> <meta name="generator" content= "HTML Tidy for Linux/x86 (vers 1st November 2002), see www.w3.org"> <title></title> </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> </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</strong></p> <p>SUNDAYS<br> "On Course"<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> PA</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> </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: $myName</strong></p> <p>$elm1</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" font-size:=""><br> <br> <a href= 'http://www.1purpose-bethel.org'>Home</a><br> <a href= 'http://www.bethel.org/'>Bethel</a><br> <a href= 'http://www.singles.ag.org/'>AG-Singles</a><br> <a href= 'http://www.bethel.org/Sermons.htm'>Sermons</a><br> <a href= 'http://www.1purpose-bethel.org/newsBriefs.php'>News</a><br> <a href= 'http://www.1purpose-bethel.org/personalGrowth.html'>Growth</a><br> <a href= 'http://www.1purpose-bethel.org/ministries.html'>Ministries</a><br> <a href= 'http://bible.oneplace.com/'>Bible Tools</a><br> <a href= 'http://www.1purpose-bethel.org/sportsFitness.php'>Fitness-Sports</a><br> <a href= 'http://www.1purpose-bethel.org/images/phpSlideshow/phpslideshow.php'> Slideshows</a><br> </span></p> </td> </tr> </table> </body> </html> HERE; // 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(); } ------------------------------------------------------------------- |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
"Matt Madrid" <admiralcap@gmail.com> wrote in message news:CaKdnT3GzJ-1XivbnZ2dnUVZ_jednZ2d@comcast.com... > Kevin Raleigh wrote: > [snip] > > > > NOTICE that the last character is an " ! " > > > > Has anyone ever had this problem before? > > No. And I can't reproduce it. I sent this same email to myself > and it worked fine. > > > Any suggestions on how to break the html code into multiple lines of code? > > Yes. You put a new line character at the end of each line. eg., > > $line = "Stuff\n"; // > ^^--- the \n is the "new line" character > > Or, you can quote the whole thing.. no need to keep appending > the $myBody var with .= , but since you have double and single > quotes in the HTML, you should use a HERE document... see my > rewrite below. I took the liberty of cleaning up your HTML using > the very cool "HTML Tidy" interface at http://infohound.net/tidy/ > > I tried it myself, and no ! at the end. Here is a rewrite of your > code (just the while loop) with $myBody quoted in a HERE document. > > Without seeing what is in $_POST['elm1'], I can't be sure that that > isn't the problem. > > Hope this s. > > Matt M. > > ------------------------------------------------------------------- > > while ($row = mysql_fetch_array ($result)) { > > $myName = trim($row['fName'], "'"); > $elm1 = $_POST['elm1']; > > $myBody = <<<HERE > <html> > <head> > <meta name="generator" content= > "HTML Tidy for Linux/x86 (vers 1st November 2002), see www.w3.org"> > <title></title> > </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> </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</strong></p> > > <p>SUNDAYS<br> > "On Course"<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> > PA</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> </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: $myName</strong></p> > <p>$elm1</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" font-size:=""><br> > <br> > <a href= > 'http://www.1purpose-bethel.org'>Home</a><br> > <a href= > 'http://www.bethel.org/'>Bethel</a><br> > <a href= > 'http://www.singles.ag.org/'>AG-Singles</a><br> > <a href= > 'http://www.bethel.org/Sermons.htm'>Sermons</a><br> > <a href= > 'http://www.1purpose-bethel.org/newsBriefs.php'>News</a><br> > <a href= > 'http://www.1purpose-bethel.org/personalGrowth.html'>Growth</a><br> > <a href= > 'http://www.1purpose-bethel.org/ministries.html'>Ministries</a><br> > <a href= > 'http://bible.oneplace.com/'>Bible Tools</a><br> > <a href= > 'http://www.1purpose-bethel.org/sportsFitness.php'>Fitness-Sports</a><br> > <a href= > 'http://www.1purpose-bethel.org/images/phpSlideshow/phpslideshow.php'> > Slideshows</a><br> > </span></p> > </td> > </tr> > </table> > </body> > </html> > HERE; > > // 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(); > } > > > ------------------------------------------------------------------- > I appreciate the That took care of the problem. I am not sure why, but it is working and that is what counts Thank You Kevin Raleigh |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Le Sun, 05 Aug 2007 00:00:33 -0700, Kevin Raleigh a écritÂ:
Hi, Don't you dare write few scripts like this! You'll go crazy after the second one )I guess I'm the glad one to teach you there is a way to bufferize standard output and then assign it to a variable. Go to php.net and search for the function ob_start(). Learn to use output buffernig, I'm sure you'll be satisfied. Julien |
|
![]() |
| Outils de la discussion | |
|
|