|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22812 mail function adds additionas <> symbols to $to parameter
Submitted: 2003-03-21 05:18 UTC Modified: 2003-03-22 21:25 UTC
From: dbakr at evalica dot com Assigned:
Status: Not a bug Package: Mail related
PHP Version: 4.3.1 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: dbakr at evalica dot com
New email:
PHP Version: OS:


 [2003-03-21 05:18 UTC] dbakr at evalica dot com
mail("Danya <>", "the subject", "test",
     "From: webmaster@$SERVER_NAME\r\n"
    ."Reply-To: webmaster@$SERVER_NAME\r\n"
    ."X-Mailer: PHP/" . phpversion());

results of running scripts

Warning: mail() [function.mail]: SMTP server response: 501 >: "@" or "." expected after "Danya" in c:\app\apache\html\smail\test.php on line 6

this error message caused by mail() function's adding additional <> symbols to "Danya <>".
resulting email addres that was sended to smtp server was "<Danya <>>". Of course, server generates error :)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-22 21:25 UTC]
The first parameter to mail() should *only* be the email address itself.  This is the documented and expected behavior for mail().  If you're curious why this is, I invite you to read the RFC relating to the SMTP protocol.

If you would like to make sure your header contains the correct real name description put a "To:" header in the fourth parameter.

mail("", "the subject", "test",
     "To: Danya <>\r\n"
    ."From: webmaster@$SERVER_NAME\r\n"
    ."Reply-To: webmaster@$SERVER_NAME\r\n"
    ."X-Mailer: PHP/" . phpversion());

 [2003-06-21 23:49 UTC] bobe at phpcodeur dot net
This tips provokes a problem on the Linux servers, the email is twice received

On Linux, if we put nothing for the first argument of the mail() function and what we add to in headers them, the email is correctly received (And a to header empty is added all the same), but it plants under Windows (SMTP error 554)

So, on the Windows servers, this tips works perfectly.

Then ? Bug or not bug ? :)
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Mar 31 19:03:40 2023 UTC