#37073 [Opn]: From: Header not being parsed correctly in generation of Return-Path header

From: Date: Thu, 13 Apr 2006 18:40:49 +0000
Subject: #37073 [Opn]: From: Header not being parsed correctly in generation of Return-Path header
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-95764@lists.php.net to get a copy of this message
ID: 37073 User updated by: junkmail-trash at cowsgo dot mu Reported By: junkmail-trash at cowsgo dot mu Status: Open Bug Type: Mail related Operating System: Windows XP / Apache PHP Version: 5.1.2 New Comment: $header (line 3) in the example code should read: $header = "From: \"Joe Bob\" <joe@bob.com>\r\n"; to match the output Previous Comments: ------------------------------------------------------------------------ [2006-04-13 18:32:10] junkmail-trash at cowsgo dot mu Description: ------------ When using PHP's mail function on Windows, the Return-Path: header is generated by PHP automatically. The value for the header is derived from the From: header supplied by the user. The problem is that if there is a name in the From: header, such as: From: "Joe Bob" <joe@bob.com> PHP will mangle the Return-Path: header as: Return-Path: <"Joe Bob <joe"@bob.com> Some MTAs will then reject the entire email for having an invalid Return-Path header. To observe this, you need to sniff the SMTP connection using a tool like tcpflow, or view the message source if it is delivered correctly. The From: header displayed by your mail client is not an indicator of the Return-Path: header. Please reference http://cr.yp.to/immhf/envelope.html for a nice human-readable interpetation of the relevant RFCs. Reproduce code: --------------- ini_set('SMTP', 'youremailserver.com'); ini_set('smtp_port', '25'); $header = "From: \"Some Guy\" <joe@duh.net>\r\n"; mail("testuser@somesite.com","Test Subject", "Test Message", $header); Expected result: ---------------- (Using Thunderbird's "View Source" option) From - Thu Apr 13 11:26:12 2006 X-Mozilla-Status: 0001 X-Mozilla-Status2: 00000000 Return-Path: <joe@bob.com> Delivered-To: testuser@somesite.com Received: (qmail 29537 invoked from network); 13 Apr 2006 18:26:14 -0000 Received: from localhost (HELO foo) (127.0.0.1) by somesite.com with SMTP; 13 Apr 2006 18:26:14 -0000 Date: Thu, 13 Apr 2006 11:26:04 -0700 Subject: Test Subject To: testuser@somesite.com From: "Joe Bob" <joe@bob.com> Test Message Actual result: -------------- (Using Thunderbird's "View Source" option) From - Thu Apr 13 11:26:12 2006 X-Mozilla-Status: 0001 X-Mozilla-Status2: 00000000 Return-Path: <"Joe Bob <joe"@bob.com> Delivered-To: testuser@somesite.com Received: (qmail 29537 invoked from network); 13 Apr 2006 18:26:14 -0000 Received: from localhost (HELO foo) (127.0.0.1) by somesite.com with SMTP; 13 Apr 2006 18:26:14 -0000 Date: Thu, 13 Apr 2006 11:26:04 -0700 Subject: Test Subject To: testuser@somesite.com From: "Joe Bob" <joe@bob.com> Test Message ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37073&edit=1

« previous php.bugs (#95764) next »