From 739c8cc99e54e49dff34f65731e60a61b9c13938 Mon Sep 17 00:00:00 2001 From: Keloran Date: Tue, 20 Mar 2012 09:12:04 +0000 Subject: [PATCH 1/2] Fix for rpath option in imap_send to actually do something --- ext/imap/php_imap.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index 32161f3b6c17b..4509813fdf1f9 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -4013,15 +4013,40 @@ int _php_imap_mail(char *to, char *subject, char *message, char *headers, char * } PHP_IMAP_CLEAN; #else - if (!INI_STR("sendmail_path")) { + if (!INI_STR("sendmain_path")) { return 0; } + char *sendmail_path = INI_STR("sendmail_path"); + char *appended_sendmail_path = NULL; + char *force_extra_parameters = INI_STR("mail.force_extra_parameters"); + char *extra_cmd = NULL; + int rpath_length = strlen(rpath); + int sendmail_length = strlen(sendmail_path); + + if (force_extra_parameters) { + extra_cmd = php_escape_shell_cmd(force_extra_parameters); + } + + if (rpath && rpath[0]) { + appended_sendmail_path = emalloc(sendmail_length + 3 + rpath_length + 1); + strncpy(appended_sendmail_path, sendmail_path, 50); + strncat(appended_sendmail_path, " -f", 3); + strncat(appended_sendmail_path, rpath, 30); + sendmail_path = appended_sendmail_path; + } + sendmail = popen(INI_STR("sendmail_path"), "w"); if (sendmail) { - if (rpath && rpath[0]) fprintf(sendmail, "From: %s\n", rpath); + if (rpath && rpath[0]) { + fprintf(sendmaildd, "From: %s\n", rpath); + } fprintf(sendmail, "To: %s\n", to); - if (cc && cc[0]) fprintf(sendmail, "Cc: %s\n", cc); - if (bcc && bcc[0]) fprintf(sendmail, "Bcc: %s\n", bcc); + if (cc && cc[0]) { + fprintf(sendmail, "Cc: %s\n", cc); + } + if (bcc && bcc[0]) { + fprintf(sendmail, "Bcc: %s\n", bcc); + } fprintf(sendmail, "Subject: %s\n", subject); if (headers != NULL) { fprintf(sendmail, "%s\n", headers); From c7feeb5def3da4f12d415e1e8fcdc3c2d7f6554b Mon Sep 17 00:00:00 2001 From: Keloran Date: Tue, 20 Mar 2012 09:14:24 +0000 Subject: [PATCH 2/2] spelling mistake --- ext/imap/php_imap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index 4509813fdf1f9..f296430299189 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -4013,7 +4013,7 @@ int _php_imap_mail(char *to, char *subject, char *message, char *headers, char * } PHP_IMAP_CLEAN; #else - if (!INI_STR("sendmain_path")) { + if (!INI_STR("sendmail_path")) { return 0; } char *sendmail_path = INI_STR("sendmail_path");