From ab7f4e1cc156c0e48f443c6d5bafcd75e4b17a3c Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Fri, 10 Apr 2015 22:28:38 -0400 Subject: [PATCH] #146 All emails will now be sent as multipart/alternative Shouldn't cause issues w/plaintext emails, and it'll make it easier to add attachments. --- inc/email_functions.inc.php | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/inc/email_functions.inc.php b/inc/email_functions.inc.php index 65bad952..6decb66f 100644 --- a/inc/email_functions.inc.php +++ b/inc/email_functions.inc.php @@ -411,13 +411,13 @@ function hesk_mail($to,$subject,$message,$htmlMessage,$cc=array(),$bcc=array()) } $boundary = sha1(uniqid()); + $plaintextMessage = $message; + $message = "--".$boundary."\n"; + $message .= "Content-Type: text/plain; charset=".$hesklang['ENCODING']."\n\n"; + $message .= $plaintextMessage."\n\n"; //Prepare the message for HTML or non-html if ($modsForHesk_settings['html_emails']) { - $plaintextMessage = $message; - $message = "--".$boundary."\n"; - $message .= "Content-Type: text/plain; charset=".$hesklang['ENCODING']."\n\n"; - $message .= $plaintextMessage."\n\n"; $message .= "--".$boundary."\n"; $message .= "Content-Type: text/html; charset=".$hesklang['ENCODING']."\n\n"; $message .= $htmlMessage."\n\n"; @@ -429,10 +429,7 @@ function hesk_mail($to,$subject,$message,$htmlMessage,$cc=array(),$bcc=array()) { // Set additional headers $headers = ''; - if ($modsForHesk_settings['html_emails']) - { - $headers .= "MIME-Version: 1.0\n"; - } + $headers .= "MIME-Version: 1.0\n"; $headers .= "From: $hesk_settings[from_header]\n"; if (count($cc) > 0) { @@ -445,10 +442,7 @@ function hesk_mail($to,$subject,$message,$htmlMessage,$cc=array(),$bcc=array()) $headers.= "Reply-To: $hesk_settings[from_header]\n"; $headers.= "Return-Path: $hesk_settings[webmaster_mail]\n"; $headers.= "Date: " . date(DATE_RFC2822) . "\n"; - if ($modsForHesk_settings['html_emails']) - { - $headers.= "Content-Type: multipart/alternative;boundary=".$boundary; - } + $headers.= "Content-Type: multipart/alternative;boundary=".$boundary; // Send using PHP mail() function ob_start(); @@ -484,14 +478,9 @@ function hesk_mail($to,$subject,$message,$htmlMessage,$cc=array(),$bcc=array()) "Subject: " . $subject, "Date: " . date(DATE_RFC2822) ); - if ($modsForHesk_settings['html_emails']) - { - array_push($headersArray,"MIME-Version: 1.0"); - array_push($headersArray,"Content-Type: multipart/alternative;boundary=".$boundary); - } else - { - array_push($headersArray,"Content-Type: text/plain; charset=" . $hesklang['ENCODING']); - } + array_push($headersArray,"MIME-Version: 1.0"); + array_push($headersArray,"Content-Type: multipart/alternative;boundary=".$boundary); + if (count($cc) > 0) { array_push($headersArray,"Cc: ".implode(',',$cc));