Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions ext/imap/php_imap.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -4016,12 +4016,37 @@ int _php_imap_mail(char *to, char *subject, char *message, char *headers, char *
if (!INI_STR("sendmail_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);
Expand Down