diff --git a/UPGRADE b/UPGRADE index 32646e67..584a0dc5 100644 --- a/UPGRADE +++ b/UPGRADE @@ -513,6 +513,9 @@ OTHER CHANGES: calls at the DID, In-Group and Call Menu level. For this to work, you must set the conf files to be rebuilt after upgrading your systems. +144. Added options for HTML formatting and UTF-8 charset in emails through the + dispo_send_email.php script. + diff --git a/docs/DISPO_SEND_EMAIL.txt b/docs/DISPO_SEND_EMAIL.txt index 83f9575f..6593bce8 100644 --- a/docs/DISPO_SEND_EMAIL.txt +++ b/docs/DISPO_SEND_EMAIL.txt @@ -1,4 +1,4 @@ -Sending email after agent dispositions a call Started: 2015-08-06 Updated: 2017-11-21 +Sending email after agent dispositions a call Started: 2015-08-06 Updated: 2020-08-14 These instructions will show you how to set up automatic emails to be sent out when an agent dispositions a call with a specific defined "sale status". @@ -15,6 +15,8 @@ UPDATE! 2017-11-20 - Added ALL-STATUSES option and called_count_trigger option UPDATE! 2017-11-21 - Added options to allow for up to 5 attachments to be sent(local files) defined in the URL +UPDATE! 2020-08-14 - Added "email_body_html" flag so the email is sent as an HTML email and not plain text + Added "email_body_utf8" flag so the email is sent with a 'utf-8' charset and not 'iso-8859-1' @@ -47,6 +49,12 @@ email_from => --A--agent_email--B-- ; subject of the email email_subject => Order confirmation --A--vendor_lead_code--B-- +; format as HTML +email_body_html + +; use UTF-8 charset +email_body_utf8 + ; body of the email email_body_begin => Hello --A--first_name--B--, diff --git a/www/agc/dispo_send_email.php b/www/agc/dispo_send_email.php index 017910f3..8fcf3d0f 100644 --- a/www/agc/dispo_send_email.php +++ b/www/agc/dispo_send_email.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2020 Matt Florell LICENSE: AGPLv2 # # This script is designed to be used in the "Dispo URL" field of a campaign # or in-group. It will send out an email to a fixed email address as defined @@ -39,6 +39,7 @@ # 190129-1855 - Added --A--RUSfullname--B-- special variable flag # 190521-1715 - Added --A--dispo--B-- and --A--dispo_name--B-- to email_body # 191013-2113 - Fixes for PHP7 +# 200814-1829 - added email_body_html, email_body_utf8 flags # $api_script = 'send_email'; @@ -141,6 +142,8 @@ $match_found=0; $k=0; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=14; +$email_format = 'TEXT'; +$email_charset = 'iso-8859-1'; # filter variables $user=preg_replace("/\'|\"|\\\\|;| /","",$user); @@ -325,6 +328,10 @@ if ($match_found > 0) {$email_from = $line; $email_from = trim(preg_replace("/.*=/",'',$email_from));} if (preg_match("/^email_subject/",$line)) {$email_subject = $line; $email_subject = trim(preg_replace("/.*=/",'',$email_subject));} + if (preg_match("/^email_body_html/",$line)) + {$email_format = 'HTML';} + if (preg_match("/^email_body_utf8/",$line)) + {$email_charset = 'utf-8';} if (preg_match("/^email_body_begin/",$line)) {$email_body = $line; $email_body = trim(preg_replace("/.*=/",'',$email_body)) . "\n"; $email_body_gather++;} } @@ -1238,8 +1245,11 @@ if ($match_found > 0) $header .= "--".$boundary.PHP_EOL; // Email content - // Content-type can be text/plain or text/html - $header .= "Content-type:text/plain; charset=iso-8859-1".PHP_EOL; + // Content-type can be text/plain or text/html, with encoding as 'iso-8859-1' or 'utf-8' charset + if (preg_match("/HTML/",$email_format)) + {$header .= "Content-type:text/html; charset=$email_charset".PHP_EOL;} + else + {$header .= "Content-type:text/plain; charset=$email_charset".PHP_EOL;} $header .= "Content-Transfer-Encoding: 7bit".PHP_EOL.PHP_EOL; $header .= "$email_body".PHP_EOL; $header .= "--".$boundary.PHP_EOL; @@ -1294,8 +1304,21 @@ if ($match_found > 0) } else { + // Email header + $header = "From: ".$email_from.PHP_EOL; + $header .= "Reply-To: ".$email_from.PHP_EOL; + $header .= "MIME-Version: 1.0".PHP_EOL; + + // Email content + // Content-type can be text/plain or text/html, with encoding as 'iso-8859-1' or 'utf-8' charset + if (preg_match("/HTML/",$email_format)) + {$header .= "Content-type:text/html; charset=$email_charset".PHP_EOL;} + else + {$header .= "Content-type:text/plain; charset=$email_charset".PHP_EOL;} + $header .= "Content-Transfer-Encoding: 7bit".PHP_EOL.PHP_EOL; + ##### sending standard email with no attachments through PHP ##### - mail("$email_to","$email_subject","$email_body", "From: $email_from"); + mail("$email_to","$email_subject","$email_body", $header); } $SQL_log = "$stmt|$stmtB|$CBaffected_rows|$email_from|$email_to|$email_subject|";