cvs: php4 /ext/standard mail.c

From: Date: Sun, 08 Jul 2001 22:30:13 +0000
Subject: cvs: php4 /ext/standard mail.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-6121@lists.php.net to get a copy of this message
shane Sun Jul 8 18:30:13 2001 EDT Modified files: /php4/ext/standard mail.c Log: Enable using an external mailer under windows. 1. this depends on the patch to fix tsrm I sent to dev 2. this provides backwards compatibility, as long as sendmail_path in the ini file is empty, the old internal mailer will be used, once sendmail_path is defined, the external sendmail program will be used. I tested with indigomail from www.indigostar.com, which provides the same command line interface as sendmail no linux. Index: php4/ext/standard/mail.c diff -u php4/ext/standard/mail.c:1.38 php4/ext/standard/mail.c:1.39 --- php4/ext/standard/mail.c:1.38 Sun Jul 8 15:09:59 2001 +++ php4/ext/standard/mail.c Sun Jul 8 18:30:11 2001 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mail.c,v 1.38 2001/07/08 19:09:59 sas Exp $ */ +/* $Id: mail.c,v 1.39 2001/07/08 22:30:11 shane Exp $ */ #include <stdlib.h> #include <ctype.h> @@ -130,7 +130,7 @@ } else { RETVAL_FALSE; } - efree (extra_cmd); + if (extra_cmd) efree (extra_cmd); } /* }}} */ @@ -140,21 +140,23 @@ { #ifdef PHP_WIN32 int tsm_err; -#else +#endif FILE *sendmail; int ret; char *sendmail_path = INI_STR("sendmail_path"); char *sendmail_cmd = NULL; -#endif + if (!sendmail_path) { #ifdef PHP_WIN32 - if (TSendMail(INI_STR("SMTP"), &tsm_err, headers, subject, to, message) != SUCCESS){ - php_error(E_WARNING, GetSMErrorText(tsm_err)); - return 0; - } + /* handle old style win smtp sending */ + if (TSendMail(INI_STR("SMTP"), &tsm_err, headers, subject, to, message) != SUCCESS){ + php_error(E_WARNING, GetSMErrorText(tsm_err)); + return 0; + } + return 1; #else - if (!sendmail_path) { return 0; +#endif } if (extra_cmd != NULL) { sendmail_cmd = emalloc (strlen (sendmail_path) + strlen (extra_cmd) + 2); @@ -165,7 +167,11 @@ sendmail_cmd = sendmail_path; } +#ifdef PHP_WIN32 + sendmail = popen(sendmail_cmd, "wb"); +#else sendmail = popen(sendmail_cmd, "w"); +#endif if (extra_cmd != NULL) efree (sendmail_cmd); @@ -177,11 +183,16 @@ } fprintf(sendmail, "\n%s\n", message); ret = pclose(sendmail); +#ifdef PHP_WIN32 + if (ret == -1) +#else #if defined(EX_TEMPFAIL) - if ((ret != EX_OK)&&(ret != EX_TEMPFAIL)) { + if ((ret != EX_OK)&&(ret != EX_TEMPFAIL)) #else - if (ret != EX_OK) { + if (ret != EX_OK) +#endif #endif + { return 0; } else { return 1; @@ -190,7 +201,6 @@ php_error(E_WARNING, "Could not execute mail delivery program"); return 0; } -#endif return 1; } /* }}} */ @@ -200,10 +210,12 @@ PHP_MINFO_FUNCTION(mail) { #ifdef PHP_WIN32 + char *sendmail_path = INI_STR("sendmail_path"); + if (!sendmail_path) php_info_print_table_row(2, "Internal Sendmail Support for Windows 4", "enabled"); -#else - php_info_print_table_row(2, "Path to sendmail", INI_STR("sendmail_path") ); + else #endif + php_info_print_table_row(2, "Path to sendmail", INI_STR("sendmail_path") ); } /* }}} */

« previous php.cvs (#6121) next »