PDA

View Full Version : mail() contents appear wrong in yahoo?


loonatik
06-07-2003, 05:47 PM
I'm using a simple mail form to mail a name and email address to a yahoo account.

<?
if($submit){
$body="
Name: $name
Email: $email
";
echo "sent $name $email";
mail("me@yahoo.com","testing",$body,"From:$email");
}
else{
echo "<form action='mail.php3' method='post'>";
echo "name <input type='text' name='name'><BR>";
echo "email <input type='text' name='email'><BR>";
echo "<input type='submit' name='submit' value='submit'>";
echo "</form>";
}
?>

The name is supposed to show up as:
Name: Some Name
Email: somebody@where.com

Instead, in yahoo everything appears on the same line continuously. I've tried adding spaces and extra line breaks but no effect. This is only in yahoo. When I test with horde, it is exactly what I want. Anyone every hv the same prob?
Thanks.

Galdo
06-07-2003, 08:59 PM
Try it like:

$body="
Name: $name\n
Email: $email\n
";

loonatik
06-09-2003, 02:27 AM
that works for yahoo but in other email systems, there are double the line breaks. i guess its just how it is interpreted and not a php prob. thanks.

michael.hd
06-09-2003, 11:41 AM
Maybe the problem can be solved by using HTML mail instead of normal plain text.

Can the mail() function be used to send HTML formatted email?

Galdo
06-09-2003, 02:54 PM
Yeah you just need to specify:

Content-Type: text/html; charset=\"ISO-8859-1\"

In the body of the message.

michael.hd
06-09-2003, 04:10 PM
Originally posted by Galdo
Yeah you just need to specify:

Content-Type: text/html; charset=\"ISO-8859-1\"

In the body of the message.

Thanks for that. I'll give it a go and see if the formatting is consistent accross mail servers.