cvs: php4 /ext/standard mail.c php_mail.h
| From: | Derick Rethans | Date: | Mon, 05 Feb 2001 21:30:30 +0000 |
| Subject: | cvs: php4 /ext/standard mail.c php_mail.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-3917@lists.php.net to get a copy of this message | ||
derick Mon Feb 5 13:30:30 2001 EDT
Modified files:
/php4/ext/standard mail.c php_mail.h
Log:
- Added a new parameter to mail() which appends aditional command line
parameters to the mail program. This is usefull to set the From headers
correctly with the -f parameter to sendmail p.e.
@- Added a new parameter to mail() which appends aditional command line
@ parameters to the mail program. (Derick)
Index: php4/ext/standard/mail.c
diff -u php4/ext/standard/mail.c:1.29 php4/ext/standard/mail.c:1.30
--- php4/ext/standard/mail.c:1.29 Sun Jan 21 09:26:43 2001
+++ php4/ext/standard/mail.c Mon Feb 5 13:30:29 2001
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mail.c,v 1.29 2001/01/21 17:26:43 rasmus Exp $ */
+/* $Id: mail.c,v 1.30 2001/02/05 21:30:29 derick Exp $ */
#include <stdlib.h>
#include <ctype.h>
@@ -75,16 +75,16 @@
RETURN_LONG((int) h);
}
-/* {{{ proto int mail(string to, string subject, string message [, string additional_headers])
+/* {{{ proto int mail(string to, string subject, string message [, string additional_headers [,
string additional_parameters]])
Send an email message */
PHP_FUNCTION(mail)
{
- pval **argv[4];
- char *to=NULL, *message=NULL, *headers=NULL, *subject=NULL;
+ pval **argv[5];
+ char *to=NULL, *message=NULL, *headers=NULL, *subject=NULL, *extra_cmd=NULL;
int argc;
argc = ZEND_NUM_ARGS();
- if (argc < 3 || argc > 4 || zend_get_parameters_array_ex(argc, argv) == FAILURE) {
+ if (argc < 3 || argc > 5 || zend_get_parameters_array_ex(argc, argv) == FAILURE) {
WRONG_PARAM_COUNT;
}
/* To: */
@@ -115,12 +115,17 @@
message = NULL;
}
- if (argc == 4) { /* other headers */
+ if (argc >= 4) { /* other headers */
convert_to_string_ex(argv[3]);
headers = (*argv[3])->value.str.val;
}
- if (php_mail(to, subject, message, headers)){
+ if (argc == 5) { /* extra options that get passed to the mailer */
+ convert_to_string_ex(argv[4]);
+ extra_cmd = (*argv[4])->value.str.val;
+ }
+
+ if (php_mail(to, subject, message, headers, extra_cmd)) {
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -128,7 +133,7 @@
}
/* }}} */
-int php_mail(char *to, char *subject, char *message, char *headers)
+int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd)
{
#ifdef PHP_WIN32
int tsm_err;
@@ -136,6 +141,7 @@
FILE *sendmail;
int ret;
char *sendmail_path = INI_STR("sendmail_path");
+ char *sendmail_cmd = NULL;
#endif
#ifdef PHP_WIN32
@@ -147,7 +153,18 @@
if (!sendmail_path) {
return 0;
}
- sendmail = popen(sendmail_path, "w");
+ if (extra_cmd != NULL) {
+ sendmail_cmd = emalloc (strlen (sendmail_path) + strlen (extra_cmd) + 2);
+ strcpy (sendmail_cmd, sendmail_path);
+ strcat (sendmail_cmd, " ");
+ strcat (sendmail_cmd, extra_cmd);
+ } else {
+ sendmail_cmd = sendmail_path;
+ }
+
+ sendmail = popen(sendmail_cmd, "w");
+ if (extra_cmd != NULL)
+ efree (sendmail_cmd);
if (sendmail) {
fprintf(sendmail, "To: %s\n", to);
Index: php4/ext/standard/php_mail.h
diff -u php4/ext/standard/php_mail.h:1.7 php4/ext/standard/php_mail.h:1.8
--- php4/ext/standard/php_mail.h:1.7 Sun Jul 23 18:39:49 2000
+++ php4/ext/standard/php_mail.h Mon Feb 5 13:30:29 2001
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_mail.h,v 1.7 2000/07/24 01:39:49 david Exp $ */
+/* $Id: php_mail.h,v 1.8 2001/02/05 21:30:29 derick Exp $ */
#ifndef PHP_MAIL_H
#define PHP_MAIL_H
@@ -26,7 +26,7 @@
PHP_FUNCTION(mail);
PHP_FUNCTION(ezmlm_hash);
PHP_MINFO_FUNCTION(mail);
-extern int php_mail(char *to, char *subject, char *message, char *headers);
+extern int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd);
#endif