php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37073 From: Header not being parsed correctly in generation of Return-Path header
Submitted: 2006-04-13 18:32 UTC Modified: 2006-04-14 11:54 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: junkmail-trash at cowsgo dot mu Assigned:
Status: Not a bug Package: Mail related
PHP Version: 5.1.2 OS: Windows XP / Apache
Private report: No CVE-ID: None
 [2006-04-13 18:32 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-13 18:40 UTC] junkmail-trash at cowsgo dot mu
$header (line 3) in the example code should read:

$header = "From: \"Joe Bob\" <joe@bob.com>\r\n";

to match the output
 [2006-04-14 11:54 UTC] sniper@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

See bug #28038
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Oct 07 23:01:27 2024 UTC