Can't send too many lines as HTML email in PHP.

liunx

Guest
I can't seem to send too many lines of text between <p> and </p> tags or between <div> and </div> tags.This is the code for the entire page:
<html>
<head>
<style>
<!--
-->
</style>
<body>
<?php
$recipent="[email protected]";
$subject="Test message.";
$message='
<html>
<head>
<style>
<!--
-->
</style>
<body background="some value" text=".." link="..." vlink="...">
<span style="position:absolute;left:20px;top:20px>
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<p>
Some text here for 7-8 lines with URLs mentioned
</p>
</td>
</tr>
</table>
</span>
</body>
</html>
';
$headers="MIME-Version:1.0\n";
$headers .="Content-type:text/html;charset=iso-8859-1\n";
$headers .="From: Someone<[email protected]>\n";
$yes=mail($recipent,$subject,$message,$headers);
if($yes) {
echo "Mail was sent.";
}else {
echo "Sorry!The mail could not be sent this time.";
}
?>
</body>
</html>
Problem-PHP doesn't parse if the orange text area in the code is more than 2 lines.I then have to split up the text there into blocks of 1-2 lines each between <p> and </p> or <div> and </div> tags and the mail gets sent.The <br> tag simply doesn't work either if the text is too voluminous for one parse stretch.

I read at this page (<!-- m --><a class="postlink" href="http://www.php.net/manual/en/function.mail.php">http://www.php.net/manual/en/function.mail.php</a><!-- m -->) that,"RFC 821 prohibits lines longer than 998 bytes, and requires that all servers be able to accept 998-byte lines. In practice, users sometimes send longer lines....So don't forget to do a "\n" at least every 998 bytes in your $message".This is an observation posted by an enthusiast there.
I tried following these directions and added \n after each line and,incase I was in error,tried adding "\n" after each line,but to no avail.

So,how do I get PHP to parse multiple lines in paras and multiple paras too for sendin HTML emails with the mail( ) function?

Pl assistbah, I send at least 200 lines of code and never used a \n in there. for one don't use ' in the variable.

$message='

that is a no no, do it like this

$message="

and then you have to escape the others you use in this variable.

so your code will look like this
and besides you forgot a " at the end of the span tag.

<html>
<head>
<style>
<!--
-->
</style>
<body>
<?php
$recipent="[email protected]";
$subject="Test message.";
$message="
<html>
<head>
<style>
<!--
-->
</style>
<body background=\"some value\" text=\"..\" link=\"...\" vlink=\"...\">
<span style=\"position:absolute;left:20px;top:20px\">
<table width=\"600\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td>
<p>
Some text here for 7-8 lines with URLs mentioned
</p>
</td>
</tr>
</table>
</span>
</body>
</html>
";
$headers="MIME-Version:1.0\n";
$headers .="Content-type:text/html;charset=iso-8859-1\n";
$headers .="From: Someone<[email protected]>\n";
$yes=mail($recipent,$subject,$message,$headers);
if($yes) {
echo "Mail was sent.";
}else {
echo "Sorry!The mail could not be sent this time.";
}
?>
</body>
</html>Yeah,scoutt.The idea crossed my mind too,but since this example was mentioned in the main php site,I thought that would be the way to do it.But the mail gets sent that way too as I mentioned in my post,but the text has to be limited to blocks of 1-2 lines.Shall try out the method suggested by you.One thing here:What if there are " signs that I have to use in my text space,i.e.,if I have to quote or something like that?Can I use that as it is or is it going to cause a parse error.Like if I have to use: "The HR chief was stationed at Frankfurt when he delivered the instructions...",he said.I hope I can use it as it is.Else,I'll get back to you for fixing it.Right?anytime you want to use " you have to escape them. sure you can put qutes in the message itself just do this

\"The HR chief was stationed at Frankfurt when he delivered the instructions...\",he said

it doesn't matter what you have, anytime you have an echo or a variable that has a quote in it you have to escpae it with the backslash.
 
Back
Top