Spurious character in email sent with mail()

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
JeffG
Forum Commoner
Posts: 35
Joined: Wed Jan 30, 2008 1:42 pm
Location: Newbury, UK

Spurious character in email sent with mail()

Post by JeffG »

I have the following code which sends an email to the maintainer (who happens to be me :) ):

Code: Select all

            // Compose and send the email
            $headers = "From: $mail_from_address"."\r\n";
            $headers .= "Reply-To: $mail_from_address"."\r\n";
            $headers .= "X-Mailer: PHP/".phpversion();

            $message = "To:   Maintainer\nFrom user: $username\n\n";
            $message .= $text;
            ini_set("track_errors", "1");
            ini_set("SMTP", $mail_smtp_host);
            $sent = mail($maint_email, $email_prefix." - ".$subject, $message, $headers);
 
The message body which is delivered is as follows:

Code: Select all

To:   Maintainer
>From user: jeff

This is a test.
Where is the spurious '>' coming from?

(Using PHP 5.2.5 on Windows 7. Browser is Firefox.)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Spurious character in email sent with mail()

Post by John Cartwright »

Your mail server is doing it for whatever reason, I have not a clue.

What happens if you try

Code: Select all

$message = "To: Maintainer\r\n";
$message.= "From user: $username\r\n";
$message.="\r\n";
JeffG
Forum Commoner
Posts: 35
Joined: Wed Jan 30, 2008 1:42 pm
Location: Newbury, UK

Re: Spurious character in email sent with mail()

Post by JeffG »

It made no difference. A weird anomaly, but something I can live with. Thanks anyway.
Post Reply