php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14407 Win32 SendMail function doesn't use "From:" in SMTP MAIL FROM command
Submitted: 2001-12-10 12:27 UTC Modified: 2002-06-02 18:55 UTC
From: msisolak at yahoo dot com Assigned:
Status: Closed Package: Mail related
PHP Version: 4.0CVS-2001-12-10 OS: Windows 2000
Private report: No CVE-ID: None
 [2001-12-10 12:27 UTC] msisolak at yahoo dot com
The SendMail function that is used for Win32 platforms doesn't extract the "From:" header address to use as for the SMTP MAIL FROM command.  As a result any mail bounces go to the "sendmail_from" php.ini option instead of to the sender.  This is handled correctly in the PostHeader function (which doesn't add "From:" if it is already there), but not in TSendMail.  The patch for win32/sendmail.c below allows TSendMail to use the e-mail from address if it is available, and default to the sendmail_from setting otherwise.

124,128c124,142
< 
< 	if (INI_STR("sendmail_from")){
< 		RPath = estrdup(INI_STR("sendmail_from"));
< 		} else {
< 			return 19;
---
> 
> 	if (headers && strstr(headers, "From:")) {
> 		char *pos;
> 		pos = strstr(headers, "From:") + 5;
> 		while (pos && (*pos == ' '))
> 			pos++;
> 
> 		if (pos && strlen(pos)) {
> 			RPath = estrdup(pos);
> 			RPath[strcspn(RPath, "\r\n")] = '\x0';
> 		}
> 	}
> 	
> 	if (!RPath) {
> 		if (INI_STR("sendmail_from")) {
> 			RPath = estrdup(INI_STR("sendmail_from"));
> 			} else {
> 				return 19;
> 		}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-14 10:02 UTC] mfischer@php.net
Can you post a unified diff against latest CVS HEAD to php-dev@lists.php.net please ?
 [2002-05-17 12:30 UTC] mfischer@php.net
Fixed in CVS.
 [2002-06-02 18:55 UTC] mfischer@php.net
I've reverted the patch. The sendmail_from ini setting is for setting the return path, which can be different from the From: header in fact.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 23:01:28 2024 UTC