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

Posted by Matt Madrid on 08/06/07 06:43

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 helps.

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>&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&lt;//strong&gt;<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>&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: $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>
&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://www.bethel.org/'>Bethel</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=
'http://www.singles.ag.org/'>AG-Singles</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=
'http://www.bethel.org/Sermons.htm'>Sermons</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=
'http://www.1purpose-bethel.org/newsBriefs.php'>News</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=
'http://www.1purpose-bethel.org/personalGrowth.html'>Growth</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=
'http://www.1purpose-bethel.org/ministries.html'>Ministries</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=
'http://bible.oneplace.com/'>Bible Tools</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=
'http://www.1purpose-bethel.org/sportsFitness.php'>Fitness-Sports</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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();
}


-------------------------------------------------------------------

 

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

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