#112 SMTP Cc/Bcc fields are working properly
This commit is contained in:
parent
975037c29d
commit
6a5de96b7d
@ -62,7 +62,24 @@ function hesk_notifyCustomerForVerifyEmail($email_template = 'verify_email', $ac
|
|||||||
$message = str_replace('%%VERIFYURL%%', $activationUrl, $message);
|
$message = str_replace('%%VERIFYURL%%', $activationUrl, $message);
|
||||||
$message = str_replace('%%ACTIVATIONKEY%%', $activationKey, $message);
|
$message = str_replace('%%ACTIVATIONKEY%%', $activationKey, $message);
|
||||||
|
|
||||||
hesk_mail($ticket['email'], $subject, $message);
|
// Add Cc / Bcc recipents if needed
|
||||||
|
$ccEmails = array();
|
||||||
|
$bccEmails = array();
|
||||||
|
foreach ($hesk_settings['custom_fields'] as $k=>$v) {
|
||||||
|
if ($v['use']) {
|
||||||
|
if ($v['type'] == 'email' && !empty($ticket[$k])) {
|
||||||
|
if ($v['value'] == 'cc') {
|
||||||
|
$emails = explode(',',$ticket[$k]);
|
||||||
|
array_push($ccEmails, $emails);
|
||||||
|
} elseif ($v['value'] == 'bcc') {
|
||||||
|
$emails = explode(',',$ticket[$k]);
|
||||||
|
array_push($bccEmails, $emails);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hesk_mail($ticket['email'], $subject, $message, $ccEmails, $bccEmails);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -80,8 +97,23 @@ function hesk_notifyCustomer($email_template = 'new_ticket')
|
|||||||
$subject = hesk_getEmailSubject($email_template,$ticket);
|
$subject = hesk_getEmailSubject($email_template,$ticket);
|
||||||
$message = hesk_getEmailMessage($email_template,$ticket);
|
$message = hesk_getEmailMessage($email_template,$ticket);
|
||||||
|
|
||||||
|
// Add Cc / Bcc recipents if needed
|
||||||
|
$ccEmails = array();
|
||||||
|
$bccEmails = array();
|
||||||
|
foreach ($hesk_settings['custom_fields'] as $k=>$v) {
|
||||||
|
if ($v['use']) {
|
||||||
|
if ($v['type'] == 'email' && !empty($ticket[$k])) {
|
||||||
|
if ($v['value'] == 'cc') {
|
||||||
|
array_push($ccEmails, $ticket[$k]);
|
||||||
|
} elseif ($v['value'] == 'bcc') {
|
||||||
|
array_push($bccEmails, $ticket[$k]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Send e-mail
|
// Send e-mail
|
||||||
hesk_mail($ticket['email'], $subject, $message);
|
hesk_mail($ticket['email'], $subject, $message, $ccEmails, $bccEmails);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -275,7 +307,7 @@ function hesk_validEmails()
|
|||||||
} // END hesk_validEmails()
|
} // END hesk_validEmails()
|
||||||
|
|
||||||
|
|
||||||
function hesk_mail($to,$subject,$message)
|
function hesk_mail($to,$subject,$message,$cc=array(),$bcc=array())
|
||||||
{
|
{
|
||||||
global $hesk_settings, $hesklang;
|
global $hesk_settings, $hesklang;
|
||||||
|
|
||||||
@ -307,6 +339,14 @@ function hesk_mail($to,$subject,$message)
|
|||||||
{
|
{
|
||||||
// Set additional headers
|
// Set additional headers
|
||||||
$headers = "From: $hesk_settings[from_header]\n";
|
$headers = "From: $hesk_settings[from_header]\n";
|
||||||
|
if (count($cc) > 0)
|
||||||
|
{
|
||||||
|
$headers .= "Cc: ".implode(',',$cc);
|
||||||
|
}
|
||||||
|
if (count($bcc) > 0)
|
||||||
|
{
|
||||||
|
$headers .= "Bcc: ".implode(',',$bcc);
|
||||||
|
}
|
||||||
$headers.= "Reply-To: $hesk_settings[from_header]\n";
|
$headers.= "Reply-To: $hesk_settings[from_header]\n";
|
||||||
$headers.= "Return-Path: $hesk_settings[webmaster_mail]\n";
|
$headers.= "Return-Path: $hesk_settings[webmaster_mail]\n";
|
||||||
$headers.= "Date: " . date(DATE_RFC2822) . "\n";
|
$headers.= "Date: " . date(DATE_RFC2822) . "\n";
|
||||||
@ -337,15 +377,28 @@ function hesk_mail($to,$subject,$message)
|
|||||||
|
|
||||||
// Send the e-mail using SMTP
|
// Send the e-mail using SMTP
|
||||||
$to_arr = explode(',',$to);
|
$to_arr = explode(',',$to);
|
||||||
if ( ! $smtp->SendMessage($hesk_settings['noreply_mail'], $to_arr, array(
|
|
||||||
"From: $hesk_settings[from_header]",
|
|
||||||
"To: $to",
|
$headersArray = array(
|
||||||
"Reply-To: $hesk_settings[from_header]",
|
"From: $hesk_settings[from_header]",
|
||||||
"Return-Path: $hesk_settings[webmaster_mail]",
|
"To: $to",
|
||||||
"Subject: " . $subject,
|
"Reply-To: $hesk_settings[from_header]",
|
||||||
"Date: " . date(DATE_RFC2822),
|
"Return-Path: $hesk_settings[webmaster_mail]",
|
||||||
"Content-Type: text/plain; charset=" . $hesklang['ENCODING']
|
"Subject: " . $subject,
|
||||||
), $message))
|
"Date: " . date(DATE_RFC2822),
|
||||||
|
"Content-Type: text/plain; charset=" . $hesklang['ENCODING']
|
||||||
|
);
|
||||||
|
if (count($cc) > 0)
|
||||||
|
{
|
||||||
|
array_push($headersArray,"Cc: ".implode(',',$cc));
|
||||||
|
}
|
||||||
|
if (count($bcc) > 0)
|
||||||
|
{
|
||||||
|
array_push($headersArray,"Bcc: ".implode(',',$bcc));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ( ! $smtp->SendMessage($hesk_settings['noreply_mail'], $to_arr, $headersArray, $message))
|
||||||
{
|
{
|
||||||
// Suppress errors unless we are in debug mode
|
// Suppress errors unless we are in debug mode
|
||||||
if ($hesk_settings['debug_mode'])
|
if ($hesk_settings['debug_mode'])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user