1 Index: php4/ext/standard/mail.c
2 ===================================================================
3 RCS file: /repository/php4/ext/standard/mail.c,v
4 retrieving revision 1.33
5 retrieving revision 1.44
7 --- php4/ext/standard/mail.c 2 Apr 2001 16:37:50 -0000 1.33
8 +++ php4/ext/standard/mail.c 25 Sep 2001 22:48:43 -0000 1.44
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
14 + | Authors: Rasmus Lerdorf <rasmus@php.net> |
15 +----------------------------------------------------------------------+
27 +#include "safe_mode.h"
35 convert_to_string_ex(pstr);
36 - if ((*pstr)->value.str.val) {
37 - str = (*pstr)->value.str.val;
38 + if (Z_STRVAL_PP(pstr)) {
39 + str = Z_STRVAL_PP(pstr);
41 php_error(E_WARNING, "Must give string parameter to ezmlm_hash()");
49 /* {{{ proto int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]])
50 Send an email message */
54 convert_to_string_ex(argv[0]);
55 - if ((*argv[0])->value.str.val) {
56 - to = (*argv[0])->value.str.val;
57 + if (Z_STRVAL_PP(argv[0])) {
58 + to = Z_STRVAL_PP(argv[0]);
60 php_error(E_WARNING, "No to field in mail command");
65 convert_to_string_ex(argv[1]);
66 - if ((*argv[1])->value.str.val) {
67 - subject = (*argv[1])->value.str.val;
68 + if (Z_STRVAL_PP(argv[1])) {
69 + subject = Z_STRVAL_PP(argv[1]);
71 php_error(E_WARNING, "No subject field in mail command");
76 convert_to_string_ex(argv[2]);
77 - if ((*argv[2])->value.str.val) {
78 - message = (*argv[2])->value.str.val;
79 + if (Z_STRVAL_PP(argv[2])) {
80 + message = Z_STRVAL_PP(argv[2]);
82 /* this is not really an error, so it is allowed. */
83 php_error(E_WARNING, "No message string in mail command");
86 if (argc >= 4) { /* other headers */
87 convert_to_string_ex(argv[3]);
88 - headers = (*argv[3])->value.str.val;
89 + headers = Z_STRVAL_PP(argv[3]);
92 if (argc == 5) { /* extra options that get passed to the mailer */
93 convert_to_string_ex(argv[4]);
94 - extra_cmd = (*argv[4])->value.str.val;
95 + extra_cmd = php_escape_shell_arg(Z_STRVAL_PP(argv[4]));
98 if (php_mail(to, subject, message, headers, extra_cmd)) {
105 + if (extra_cmd) efree (extra_cmd);
109 -int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd)
112 +PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd)
120 char *sendmail_path = INI_STR("sendmail_path");
121 char *sendmail_cmd = NULL;
124 + if (!sendmail_path) {
126 - if (TSendMail(INI_STR("SMTP"), &tsm_err, headers, subject, to, message) != SUCCESS){
127 - php_error(E_WARNING, GetSMErrorText(tsm_err));
130 + /* handle old style win smtp sending */
131 + if (TSendMail(INI_STR("SMTP"), &tsm_err, headers, subject, to, message) != SUCCESS){
132 + php_error(E_WARNING, GetSMErrorText(tsm_err));
137 - if (!sendmail_path) {
141 if (extra_cmd != NULL) {
142 sendmail_cmd = emalloc (strlen (sendmail_path) + strlen (extra_cmd) + 2);
144 sendmail_cmd = sendmail_path;
148 + sendmail = popen(sendmail_cmd, "wb");
150 sendmail = popen(sendmail_cmd, "w");
152 if (extra_cmd != NULL)
153 efree (sendmail_cmd);
155 @@ -170,11 +182,16 @@
157 fprintf(sendmail, "\n%s\n", message);
158 ret = pclose(sendmail);
162 #if defined(EX_TEMPFAIL)
163 - if ((ret != EX_OK)&&(ret != EX_TEMPFAIL)) {
164 + if ((ret != EX_OK)&&(ret != EX_TEMPFAIL))
166 - if (ret != EX_OK) {
174 @@ -183,18 +200,27 @@
175 php_error(E_WARNING, "Could not execute mail delivery program");
183 +/* {{{ PHP_MINFO_FUNCTION
185 PHP_MINFO_FUNCTION(mail)
187 + char *sendmail_path = INI_STR("sendmail_path");
190 - php_info_print_table_row(2, "Internal Sendmail Support for Windows 4", "enabled");
191 + if (!sendmail_path) {
192 + php_info_print_table_row(2, "Internal Sendmail Support for Windows", "enabled");
194 + php_info_print_table_row(2, "Path to sendmail", sendmail_path);
197 - php_info_print_table_row(2, "Path to sendmail", INI_STR("sendmail_path") );
198 + php_info_print_table_row(2, "Path to sendmail", sendmail_path);
213 + * c-basic-offset: 4
215 + * vim600: sw=4 ts=4 fdm=marker
216 + * vim<600: sw=4 ts=4