-@@ -113,41 +116,46 @@
-
- if (argc >= 4) { /* other headers */
- convert_to_string_ex(argv[3]);
-- headers = (*argv[3])->value.str.val;
-+ headers = Z_STRVAL_PP(argv[3]);
- }
-
- if (argc == 5) { /* extra options that get passed to the mailer */
- convert_to_string_ex(argv[4]);
-- extra_cmd = (*argv[4])->value.str.val;
-+ extra_cmd = php_escape_shell_arg(Z_STRVAL_PP(argv[4]));
- }
-
- if (php_mail(to, subject, message, headers, extra_cmd)) {
-- RETURN_TRUE;
-+ RETVAL_TRUE;
- } else {
-- RETURN_FALSE;
-+ RETVAL_FALSE;
- }
-+ if (extra_cmd) efree (extra_cmd);
- }
- /* }}} */
-
--int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd)
-+/* {{{ php_mail
-+ */
-+PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd)
- {
- #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);
-@@ -158,7 +166,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);
-
-@@ -170,11 +182,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;
-@@ -183,18 +200,27 @@
- php_error(E_WARNING, "Could not execute mail delivery program");
- return 0;
- }
--#endif
- return 1;
- }
-+/* }}} */
-
-+/* {{{ PHP_MINFO_FUNCTION
-+ */
- PHP_MINFO_FUNCTION(mail)
- {
-+ char *sendmail_path = INI_STR("sendmail_path");
-+
- #ifdef PHP_WIN32
-- php_info_print_table_row(2, "Internal Sendmail Support for Windows 4", "enabled");
-+ if (!sendmail_path) {
-+ php_info_print_table_row(2, "Internal Sendmail Support for Windows", "enabled");
-+ } else {
-+ php_info_print_table_row(2, "Path to sendmail", sendmail_path);
-+ }
- #else
-- php_info_print_table_row(2, "Path to sendmail", INI_STR("sendmail_path") );
-+ php_info_print_table_row(2, "Path to sendmail", sendmail_path);
- #endif
- }
-+/* }}} */
-
- #else
-
-@@ -203,9 +229,11 @@
-
- #endif
-
--
- /*
- * Local variables:
- * tab-width: 4
-+ * c-basic-offset: 4
- * End:
-+ * vim600: sw=4 ts=4 fdm=marker
-+ * vim<600: sw=4 ts=4
- */