php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #14166 patch for mail() to use sendmail_from on Unix
Submitted: 2001-11-21 14:49 UTC Modified: 2003-02-26 14:15 UTC
From: sury dot ondrej at globe dot cz Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.6 OS: Linux
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: sury dot ondrej at globe dot cz
New email:
PHP Version: OS:

 

 [2001-11-21 14:49 UTC] sury dot ondrej at globe dot cz
This patch allows setup Return-path: per virtual host
and thus identify real sender of mail message.  It is
really usefull to identify source of spam and such.

O.

--- php4-4.0.100.orig/ext/standard/mail.c	Mon Jul 30 08:18:06 2001
+++ php4-4.0.100/ext/standard/mail.c	Wed Nov 21 20:44:53 2001
@@ -142,8 +142,10 @@
 #endif
 	FILE *sendmail;
 	int ret;
+	static int sendmail_cmd_len = 0;
 	char *sendmail_path = INI_STR("sendmail_path");
-	char *sendmail_cmd = NULL;
+	char *sendmail_from = INI_STR("sendmail_from");
+	char *sendmail_cmd  = NULL;
 
 	if (!sendmail_path) {
 #ifdef PHP_WIN32
@@ -157,11 +159,18 @@
 		return 0;
 #endif
 	}
-	if (extra_cmd != NULL) {
-		sendmail_cmd = emalloc (strlen (sendmail_path) + strlen (extra_cmd) + 2);
+	if ((extra_cmd != NULL) || (sendmail_from != NULL)) {
+		sendmail_cmd = emalloc (((extra_cmd != NULL)?strlen(extra_cmd)+1:0) +
+			((sendmail_from != NULL)?strlen(sendmail_from)+3:0) + strlen(sendmail_path) + 1);
 		strcpy (sendmail_cmd, sendmail_path);
-		strcat (sendmail_cmd, " ");
-		strcat (sendmail_cmd, extra_cmd);
+		if (extra_cmd != NULL) {
+			strcat (sendmail_cmd, " ");
+			strcat (sendmail_cmd, extra_cmd);
+		}
+		if (sendmail_from != NULL) {
+			strcat (sendmail_cmd, " -f");
+			strcat (sendmail_cmd, sendmail_from);
+		}
 	} else {
 		sendmail_cmd = sendmail_path;
 	}
@@ -171,7 +180,7 @@
 #else
 	sendmail = popen(sendmail_cmd, "w");
 #endif
-	if (extra_cmd != NULL)
+	if ((extra_cmd != NULL) || (sendmail_from != NULL))
 		efree (sendmail_cmd);
 
 	if (sendmail) {


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-26 14:15 UTC] derick@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

From PHP 5 you can force the extra parameters to be set with the ini setting "mail_force_extra_parameters", see also:
http://news.php.net/article.php?group=php.cvs&article=19210

Derick

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 17 21:01:27 2024 UTC