From:             [EMAIL PROTECTED]
Operating system: Linux
PHP version:      4.0.6
PHP Bug Type:     Feature/Change Request
Bug description:  patch for mail() to use sendmail_from on Unix

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) {


-- 
Edit bug report at: http://bugs.php.net/?id=14166&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to