FIX_Mail Fixes
This commit is contained in:
parent
723a532212
commit
1c75413b64
@ -258,7 +258,7 @@ class NotificationController extends AdminController
|
||||
|
||||
$template_id = $this->request->getPost('template_id');
|
||||
|
||||
$test_mail = $this->request->getPost('test_mail');
|
||||
// $test_mail = $this->request->getPost('test_mail');
|
||||
|
||||
$test_mail_list = $this->request->getPost('test_mail_list');
|
||||
|
||||
@ -268,27 +268,67 @@ class NotificationController extends AdminController
|
||||
|
||||
if(!empty($notification_data)){
|
||||
|
||||
$params = [
|
||||
'client_data' => $client_data,
|
||||
'notification_data' => $notification_data,
|
||||
'test_mail' => $test_mail,
|
||||
'test_mail_list' => $test_mail_list
|
||||
];
|
||||
// First Index as test mail all are testmaillist
|
||||
// $params = [
|
||||
// 'client_data' => $client_data,
|
||||
// 'notification_data' => $notification_data,
|
||||
// 'test_mail' => $test_mail,
|
||||
// 'test_mail_list' => $test_mail_list
|
||||
// ];
|
||||
// $testMailData = sendMailNotification::sendMailNotificationForTesting($notification_data['template_name'], $params);
|
||||
// if (!empty($testMailData)) {
|
||||
// $mail_send_return1 = MailHelper::send_email($testMailData);
|
||||
// $this->myLogger->logme("info", $mail_send_return1);
|
||||
// $this->myLogger->logme("info", $mail_send_return1);
|
||||
// return $this->respond(['status' => true,'code' => 200, 'respond' => json_decode($mail_send_return1)]);
|
||||
// }else{
|
||||
// return $this->respond(['status' => false,'code' => 200, 'message' => 'Test Mail Data Does Not Exist']);
|
||||
// }
|
||||
|
||||
$testMailData = sendMailNotification::sendMailNotificationForTesting($notification_data['template_name'], $params);
|
||||
// print_r($testMailData); die;
|
||||
if (!empty($testMailData)) {
|
||||
|
||||
$mail_send_return1 = MailHelper::send_email($testMailData);
|
||||
$this->myLogger->logme("info", $mail_send_return1);
|
||||
$this->myLogger->logme("info", $mail_send_return1);
|
||||
$mailArray = explode(',', $test_mail_list);
|
||||
$successMails = [];
|
||||
$failedMails = [];
|
||||
|
||||
return $this->respond(['status' => true,'code' => 200, 'respond' => json_decode($mail_send_return1)]);
|
||||
foreach ($mailArray as $singleMail) {
|
||||
$singleMail = trim($singleMail);
|
||||
|
||||
}else{
|
||||
$params = [
|
||||
'client_data' => $client_data,
|
||||
'notification_data' => $notification_data,
|
||||
'test_mail' => $singleMail,
|
||||
'test_mail_list' => "" // optional
|
||||
];
|
||||
|
||||
$testMailData = sendMailNotification::sendMailNotificationForTesting($notification_data['template_name'], $params);
|
||||
|
||||
if (!empty($testMailData)) {
|
||||
$mail_send_return1 = MailHelper::send_email($testMailData);
|
||||
|
||||
if ($mail_send_return1) {
|
||||
$successMails[] = $singleMail;
|
||||
} else {
|
||||
$failedMails[] = $singleMail;
|
||||
}
|
||||
|
||||
$this->myLogger->logme("info", "Mail attempt to {$singleMail}: " . $mail_send_return1);
|
||||
} else {
|
||||
$failedMails[] = $singleMail;
|
||||
$this->myLogger->logme("info", "Test Mail Data Does Not Exist for {$singleMail}");
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare final response
|
||||
if (!empty($successMails)) {
|
||||
$responseMessage = "Count " . count($successMails) . " mail(s) sent successfully: \n" . implode("\n", $successMails);
|
||||
if (!empty($failedMails)) {
|
||||
$responseMessage .= "\nCount " . count($failedMails) . " mail(s) failed: \n" . implode("\n", $failedMails);
|
||||
}
|
||||
return $this->respond(['status' => true,'code' => 200,'message' => $responseMessage]);
|
||||
} else {
|
||||
return $this->respond(['status' => false,'code' => 200,'message' => 'All mails failed to send: ' . implode(", ", $failedMails)]);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => false,'code' => 200, 'message' => 'Test Mail Data Does Not Exist']);
|
||||
}
|
||||
}else{
|
||||
|
||||
return $this->respond(['status' => false,'code' => 200, 'message' => 'Notification Template not enabled']);
|
||||
|
||||
@ -318,7 +318,7 @@ class MailHelper
|
||||
$attachments = isset($params['attachments']) ? $params['attachments'] : [];
|
||||
$common = isset($params['common']) ? $params['common'] : '';
|
||||
$bcc = isset($params['bcc']) ? $params['bcc'] : '';
|
||||
$cc = isset($params['cc']) ? $params['cc'] : '';
|
||||
$cc = (isset($params['cc']) && !empty($params['cc'])) ? $params['cc'] : '';
|
||||
|
||||
$from_address = isset($params['from_mail']) && !empty($params['from_mail']) ? $params['from_mail'] : getenv('email.fromEmail');
|
||||
// $from_address = "claims@nhanceindia.in";
|
||||
|
||||
@ -1368,7 +1368,7 @@
|
||||
let test_mail_list = $('#common_mail').val();
|
||||
|
||||
|
||||
let test_mail = test_mail_list.split(',')[0] ?? '';
|
||||
let test_mail = test_mail_list.split(',')[0] ?? ''; //REF:SVM
|
||||
|
||||
if (test_mail !== null || test_mail !== "") {
|
||||
|
||||
@ -1400,30 +1400,19 @@
|
||||
type: "POST",
|
||||
data:{
|
||||
template_id,
|
||||
test_mail,
|
||||
test_mail_list
|
||||
test_mail_list,
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
|
||||
console.log('Test mail send function response', res)
|
||||
console.log('Test mail send function response', res);
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
if (res.status == true) {
|
||||
|
||||
let respond = res.respond;
|
||||
console.log('Parsed respond', respond)
|
||||
|
||||
if (respond.status == 'success') {
|
||||
toastr.success(respond.message, 'SUCCESS')
|
||||
} else {
|
||||
toastr.warning(respond.message, 'WARNING')
|
||||
}
|
||||
|
||||
if (res.status === true) {
|
||||
toastr.success(res.message, 'SUCCESS');
|
||||
} else {
|
||||
toastr.warning('Failed to sent mail', 'WARNING')
|
||||
toastr.warning('Failed to send mail', 'WARNING');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user