header instead of sendmail_from in php.ini
| Bug #28976 | use From: header instead of sendmail_from in php.ini | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2004-06-30 18:19 UTC | Modified: | 2005-01-19 18:41 UTC |
|
||||||||||
| From: | kdaniel at aosepc dot com | Assigned: | ||||||||||||
| Status: | Closed | Package: | Mail related | |||||||||||
| PHP Version: | 4.3.6 | OS: | Windows\Apache | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2004-06-30 18:19 UTC] kdaniel at aosepc dot com
Description: ------------ The mail function always sticks in the Return-Path header based on the php.ini setting even though the email address does not correspond with the From header. There needs to be a way to either disable the Return-Path header from being inserted into the mail headers or the Return-Path should use the From header email address. Reproduce code: --------------- $To = "kdaniel@aosepc.com"; $Text = "This is a test."; $Html = "<H1>This is a test.</H1>"; $Subject = "PHP Mail Test"; $message = ""; $headers = "From: kdaniel@aosepc.com\n"; $headers .= "X-Mailer: PHP4\n"; $headers .= "X-Priority: 3\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/alternative; boundary=\"==MIME_BOUNDRY_alt_main_message\"\n\n"; $headers .= "This part of the E-mail should never be seen. If you are reading this, consider upgrading your e-mail client to a MIME-compatible client."; $message .= "--==MIME_BOUNDRY_alt_main_message\n"; $message .= "Content-Type: text/plain; charset=ISO-8859-1\n"; $message .= "Content-Transfer-Encoding: 7bit\n\n"; $message .= $Text . "\n\n"; $message .= "--==MIME_BOUNDRY_alt_main_message\n"; $message .= "Content-Type: text/html; charset=ISO-8859-1\n"; $message .= "Content-Transfer-Encoding: 7bit\n\n"; $message .= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n"; $message .= "<HTML><BODY>\n"; $message .= $Html . "\n"; $message .= "</BODY></HTML>\n\n"; $message .= "--==MIME_BOUNDRY_alt_main_message--\n"; mail($To, $Subject, $message, $headers); Expected result: ---------------- Microsoft Mail Internet Headers Version 2.0 Received: from server ([ipaddress]) by servername.com with Microsoft SMTPSVC(6.0.3790.0); Wed, 30 Jun 2004 12:16:25 -0400 Date: Wed, 30 Jun 2004 12:16:41 -0500 Subject: PHP Mail Test To: kdaniel@aosepc.com From: kdaniel@aosepc.com X-Mailer: PHP4 X-Priority: 3 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="==MIME_BOUNDRY_alt_main_message" Return-Path: kdaniel@aosepc.com Message-ID: <TCOHEPC033sl3xbYiMC00000824@servername.com> X-OriginalArrivalTime: 30 Jun 2004 16:16:25.0817 (UTC) FILETIME=[9794FC90:01C45EBD] --==MIME_BOUNDRY_alt_main_message Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit --==MIME_BOUNDRY_alt_main_message Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit --==MIME_BOUNDRY_alt_main_message-- Actual result: -------------- You will notice that the Return-Path header uses the php.ini setting and not the From header. Microsoft Mail Internet Headers Version 2.0 Received: from server ([ipaddress]) by servername.com with Microsoft SMTPSVC(6.0.3790.0); Wed, 30 Jun 2004 12:16:25 -0400 Date: Wed, 30 Jun 2004 12:16:41 -0500 Subject: PHP Mail Test To: kdaniel@aosepc.com From: kdaniel@aosepc.com X-Mailer: PHP4 X-Priority: 3 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="==MIME_BOUNDRY_alt_main_message" Return-Path: mrn@aosepc.com Message-ID: <TCOHEPC033sl3xbYiMC00000824@servername.com> X-OriginalArrivalTime: 30 Jun 2004 16:16:25.0817 (UTC) FILETIME=[9794FC90:01C45EBD] --==MIME_BOUNDRY_alt_main_message Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit --==MIME_BOUNDRY_alt_main_message Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit --==MIME_BOUNDRY_alt_main_message--
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2004-07-06 15:32 UTC] sniper@php.net
[2004-07-21 04:04 UTC] kdaniel at aosepc dot com
[2004-08-06 19:27 UTC] hholzgra@php.net
[2004-08-06 21:39 UTC] kdaniel at aosepc dot com
[2004-08-18 23:07 UTC] dv at josheli dot com
using cli PHP 5 and latest snap (php5-win32-200408181430), the extra "From:" header does not seem to work. test.php: <?php mail('test@example.com','subject','body',"From: me@example.com\r\n"); ?> Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in C:\dev\quiktests\test.php on line 3[2004-08-23 19:02 UTC] joe at inexo dot com
[2004-11-04 16:53 UTC] Charlesk at netgaintechnology dot com
It seems to me that this was thought of but never implemented. In sendmail.c: if (headers) { char *pos = NULL; size_t i; /* Use PCRE to trim the header into the right format */ if (NULL == (headers = php_win32_mail_trim_header(headers TSRMLS_CC))) { *error = W32_SM_PCRE_ERROR; return FAILURE; } /* Create a lowercased header for all the searches so we're finally case * insensitive when searching for a pattern. */ if (NULL == (headers_lc = estrdup(headers))) { efree(headers); *error = OUT_OF_MEMORY; return FAILURE; } for (i = 0; i < strlen(headers_lc); i++) { headers_lc[i] = tolower(headers_lc[i]); } } /* Fall back to sendmail_from php.ini setting */ if (mailRPath && *mailRPath) { RPath = estrdup(mailRPath); } else if (INI_STR("sendmail_from")) { RPath = estrdup(INI_STR("sendmail_from")); } else { if (headers) { efree(headers); efree(headers_lc); } *error = W32_SM_SENDMAIL_FROM_NOT_SET; return FAILURE; } I would think that in the if (headers) section there should be some code to set the mailRPath if the From header is found in headers. That way when it falls into the if (mailRPath && *mailRPath) section it will appropriately assign the from to the return path. Can this be fixed soon? Thanks Charles[2005-01-02 15:48 UTC] alexhuang at anet dot net dot tw
[2005-01-19 18:41 UTC] sniper@php.net