php.net |  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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dbakr at evalica dot com
New email:
PHP Version: OS:

 

 [2003-03-21 05:18 UTC] dbakr at evalica dot com
mail("Danya <dbakr@evalica.com>", "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 <dbakr@evalica.com>".
resulting email addres that was sended to smtp server was "<Danya <dbakr@evalica.com>>". Of course, server generates error :)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-22 21:25 UTC] pollita@php.net
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("dbakr@evalica.com", "the subject", "test",
     "To: Danya <dbakr@evalica.com>\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