Using mail function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rid243
Forum Newbie
Posts: 5
Joined: Thu Oct 08, 2009 11:27 pm

Using mail function

Post by rid243 »

Hi all,

I get strange outputs from my email function. My code:

//START
$headers = "From: Richard <richard@email.com>\n";
$headers .= 'Bcc: richard@email.com' . "\r\n";
$headers .= "Return-Path: <richard@email.com>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/HTML; charset=ISO-8859-1\n";

$subject = 'email confirmation';
$to = $email;

$body .= " * Melbourne: (03) 9000 0000<br>";
$body .= " * Newcastle: (02) 9000 0000<br>";
$body .= " * Perth: (08) 9000 0000<br>";
$body .= " * Rockhampton: (07) 9000 00000<br>";
$body .= " * Sydney: (02) 9000 0000<br>";

mail($to, $subject, $body, $headers, "-f richard@email.com");
//END

For some reason, it generates the email perfectly fine in several instances, but then it gives something like "* Melbourne: (03) 9000 00 00" in the output -- i.e. it adds a space between the four 0's. In another instance, the "<br>" tag was displayed. I'm viewing all of these emails from Gmail and can't understand why it's not consistent?

Any pointers, suggestions etc would be great.

Thanks in advance!
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Using mail function

Post by requinix »

Could have something to do with the improper headers. They should have a \r\n between each - like you did with Bcc.
Post Reply