php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29122 mail function ignoring -f arg as 5th argument
Submitted: 2004-07-13 18:23 UTC Modified: 2004-08-03 09:48 UTC
Votes:4
Avg. Score:4.5 ± 0.9
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:0 (0.0%)
From: brian dot foddy at nwa dot com Assigned: derick (profile)
Status: Closed Package: Mail related
PHP Version: 5.0.0 OS: Solaris 2.8
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: brian dot foddy at nwa dot com
New email:
PHP Version: OS:

 

 [2004-07-13 18:23 UTC] brian dot foddy at nwa dot com
Description:
------------
The mail functions additional parameters
argument is ignoring a "-f" argument.  I need
to send sendmail a -f argument to change the 
Return-Path outbound header to get past some
email spam settings.
This same code worked fine in the previous version
I used (4.2.3).

Configure as reported by phpinfo:
'./configure' '--with-apxs=/apps/soc/apache/bin/apxs' '--prefix=/apps/soc/apache/php5' '--with-sybase-ct=/apps/soc/sybase/OCS-12_0' '--enable-track-vars' '--with-config-file-path=/apps/soc/apache/php5' '--enable-trans-sid' '--with-ldap' '--enable-soap' '--with-libxml-dir=/apps/soc/' '--with-mysql=/apps/soc/mysql/'

Running on Apache 1.3.22, Solaris 2.8 Ultrasparc
V880 machine.

Reproduce code:
---------------
<?php
	$t_headers = "From:  brian.foddy@nwa.com\n";
	$t_headers .= "X-Sender: xsender@nwa.com\n";
	$t_headers .= 'X-Mailer: PHP/'.phpversion()."\n";
	$t_headers .= "Mailing-List:  SOC Issue Tracking - Mantis\n";
	$t_headers .= "Content-Type: text/plain; charset=iso-8859-1\n";
	$t_recipient = "brian.foddy@nwa.com";
	$t_subject = "Subject line";
	$t_message = "This is a test message.\n";
	$t_message .= `date`;
	$result = mail( $t_recipient, $t_subject, $t_message, $t_headers, "-fapache@nwa.com");
	if ( TRUE != $result ) {
		PRINT "PROBLEMS SENDING MAIL TO: $t_recipient<br />";
		exit;
	}
	print nl2br($t_message);
	print ("<BR>Done");
?>

Expected result:
----------------
The resulting email should have a
Return-Path:  apache@nwa.com

Actual result:
--------------
Actual Return-Path in header is still raw machine
name.  Actual full email and header:


X-UIDL: AAwojxcAAAwkL59LRkTWhqUambbW6YDo
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
Received: from FMMSPJ34.pad.nwa.com ([139.72.12.25]) by AMMSPJ28.pad.nwa.com with Microsoft SMTPSVC(5.0.2195.5329);
     Tue, 13 Jul 2004 11:02:39 -0500
Received: from j1xrms01.nwa.com ([139.72.109.167]) by FMMSPJ34.pad.nwa.com with Microsoft SMTPSVC(5.0.2195.6713);
     Tue, 13 Jul 2004 11:02:38 -0500
Received: from j0xsas04.nwa.com (j0xsas04.nwa.com [139.72.109.213])
    by j1xrms01.nwa.com (AIX4.3/8.9.3/8.9.3/NWA/990401/MAILHUB) with SMTP id LAA224760
    for <brian.foddy@nwa.com>; Tue, 13 Jul 2004 11:02:38 -0500
Received: from f1xsds01.mn.nwa.com ([139.72.25.101])
 by j0xsas04.nwa.com (SMSSMTP 4.0.0.59) with SMTP id M2004071311023832599
 for <brian.foddy@nwa.com>; Tue, 13 Jul 2004 11:02:38 -0500
Received: (from apache@localhost)
    by f1xsds01.mn.nwa.com (8.11.7p1+Sun/8.11.7) id i6DG2c705433;
    Tue, 13 Jul 2004 16:02:38 GMT
Date: Tue, 13 Jul 2004 16:02:38 GMT
Message-Id: <200407131602.i6DG2c705433@f1xsds01.mn.nwa.com>
To: brian.foddy@nwa.com
Subject: Subject line
From: brian.foddy@nwa.com
X-Sender: xsender@nwa.com
X-Mailer: PHP/5.0.0RC3
Mailing-List:  SOC Issue Tracking - Mantis
Content-Type: text/plain; charset=iso-8859-1
Return-Path: apache@f1xsds01.mn.nwa.com
X-OriginalArrivalTime: 13 Jul 2004 16:02:38.0925 (UTC) FILETIME=[D21607D0:01C468F2]


This is a test message.
Tue Jul 13 11:02:38 CDT 2004


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-14 05:28 UTC] curt@php.net
what is the output of:
echo ini_get('sendmail_from');
echo ini_get('sendmail_path');
before you call mail()

And does the sendmail you are using support the -f option?

 [2004-07-14 05:49 UTC] brian dot foddy at nwa dot com
The results as requested:
From= [me@localhost.com]
Path = [/usr/lib/sendmail -t -i]

Yes, it supports the -f option, my temporary workaround was
the following code snippet instead of calling mail()
$tmp_msg_string = "To: $t_recipient\nSubject:  $t_subject\n$t_headers\n\n$t_message\n";
$tmp_handle = popen ("/usr/lib/sendmail -fapache@nwa.com $t_recipient", "w");
fwrite ($tmp_handle, $tmp_msg_string);
$result = pclose ($tmp_handle);

which worked fine as expected.
 [2004-07-14 17:58 UTC] curt@php.net
you're workaround is exactly how php's mail() sends the data, minus the ini setting to use -t -i.  So I dont see how a different return path is being sent.

Looking at your headers, it does seem suspect that return-path isn't the first line, It appears that mozilla is doing some header mangling. 

Can you obtain the raw headers that are being set?

 [2004-07-14 21:19 UTC] brian dot foddy at nwa dot com
I hope this is what you want...
I changed the external TO address from
brian.foddy to "a26811" which is my
local user id on the server in question,
so the local sendmail did no further forwarding
or sending to external hosts.  The resulting
full message looks like:
============================================
From apache Wed Jul 14 19:14:27 2004
Return-Path: <apache>
Received: (from apache@localhost)
        by f1xsds01.mn.nwa.com (8.11.7p1+Sun/8.11.7) id i6EJEQ218348;
        Wed, 14 Jul 2004 19:14:26 GMT
Date: Wed, 14 Jul 2004 19:14:26 GMT
Message-Id: <200407141914.i6EJEQ218348@f1xsds01.mn.nwa.com>
To: a26811
Subject: Subject line
From: brian.foddy@nwa.com
X-Sender: xsender@nwa.com
X-Mailer: PHP/5.0.0RC3
Mailing-List:  SOC Issue Tracking - Mantis
Content-Type: text/plain; charset=iso-8859-1
Content-Length: 55
Status: RO


This is a test message.
Wed Jul 14 14:14:26 CDT 2004
===================================
 [2004-07-23 01:34 UTC] gem at rellim dot com
Found the problem(s).  

I had exactly the same problem.  Setting the 5th parm to "-fxxx" works perfectly in 4.3.6, It also works perfectly from command line.  PHP Fails to use "-f" since I updated to 5.0.0.

A diff of the old code in ext/standard/mail.c shows the new mail.force_extra_parameters option but no other obvious related changes.

Safe Mode=On would kill the 5th parameter, but that is off.
mail.force_extra_parameters is empty.

Forcing mail.force_extra_parameters to -fxxx in php.ini does not work.

BTW, that parameter is MISSPELLED in the sample config files
php.ini-dist and php.ini-recommended as well as the NEWS file.

AHH, there is the problem this line:
char *force_extra_parameters = INI_STR("mail_force_extra_parameters");

Should read this way:

char *force_extra_parameters = INI_STR("mail.force_extra_parameters");

Notice the mail_force should be mail.force.  Stupid typo!
 [2004-07-23 14:15 UTC] lgm2 at noos dot fr
Same problem with PHP5.0.0 under redhat.
 [2004-07-23 14:24 UTC] lgm2 at noos dot fr
Fix from gem at rellim dot com is fine.

Thanks.
 [2004-08-02 11:13 UTC] derick@php.net
I think I broke it, so I'll fix it too.
 [2004-08-03 09:48 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 20:01:31 2024 UTC