From d26a8f79484b7c8ef3a08459149772d5b1b520c9 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 11 Oct 2024 09:38:19 +0530 Subject: [PATCH] CHANGE_MAIL_REPLY_TO_SETUP : RV --- app/Helpers/MailHelper.php | 13 +++++++++++-- app/Helpers/sendMailNotification.php | 24 +++++++++++++++++------- app/Models/ClientModel.php | 1 + 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/app/Helpers/MailHelper.php b/app/Helpers/MailHelper.php index 9ff6a624..bddd1a49 100755 --- a/app/Helpers/MailHelper.php +++ b/app/Helpers/MailHelper.php @@ -93,6 +93,8 @@ class MailHelper $emaill = $params['mail']; $subject = $params['subject']; $message = $params['message']; + + //check BCC mail if (isset($params['bcc'])) { $bcc = $params['bcc']; $bcc = explode(',', $bcc); @@ -100,16 +102,23 @@ class MailHelper $bcc = []; } + //check CC mail if (isset($params['cc'])) { $cc = $params['cc']; $cc = explode(',', $cc); }else{ $cc = []; } + + //check REPLY TO mail + $reply_to = ""; + if(isset($params['reply_to']) && !empty($params['reply_to'])){ + $reply_to = $params['reply_to']; + } + try { - - $res = $gmailapi->sendMessage($emaill, $subject, $message, 'info@nhanceindia.in', 'info@nhanceindia.in', $cc, $bcc); + $res = $gmailapi->sendMessage($emaill, $subject, $message, 'info@nhanceindia.in', $reply_to, $cc, $bcc); if($res['status']) { diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index 5779135f..2802701a 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -14,6 +14,7 @@ class sendMailNotification { $wholeData =[]; if ($action == 'member_welcome_mail') { + $dataToInsert = $params['dataToInsert']; $notification = $params['notification']; $client_data = $params['client_data']; @@ -33,10 +34,13 @@ class sendMailNotification $mail_content = str_replace("[[app_link]]", "Review Details", $mail_content); if ($dataToInsert['relationship'] == 'Self' && $mail != null || $mail != '') { - $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails']]; + $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; } + return $wholeData; + } else if($action == 'member_reminder_mail'){ + $EmployeeModel = new EmployeeModel(); $emp_data = $params['emp_data']; $notification_data = $params['notification_data']; @@ -72,9 +76,11 @@ class sendMailNotification } if (isset($mail) && !empty($mail)) { - $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']]; + $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; } + }else{ + foreach ($emp_data as $key => $value) { if ($value['relationship'] != 'Self') { $emp_data = $EmployeeModel->where('client_id', $client_data['id'])->where('emp_code', $value['emp_code'])->where('is_active',1)->findAll(); @@ -96,7 +102,7 @@ class sendMailNotification $mail = $value['email_corporate']; } if (isset($mail) && !empty($mail)) { - $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']]; + $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; } } } @@ -104,10 +110,13 @@ class sendMailNotification if (count($wholeData) < 1) { $wholeData = []; } + return $wholeData; + // }else{ // return "false"; // } + } else if($action == 'member_ecard_mail'){ $notification = $params['notification']; @@ -144,9 +153,10 @@ class sendMailNotification // $mail_content = str_replace("[[tpa_id]]", $tpa_id, $mail_content); $mail_content = str_replace("[[ecard_download_link]]", "Download Insurance Card", $mail_content); $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content); - $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails']]; + $wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; return $wholeData; + } else if($action == 'member_review_and_summary_mail'){ $array_list = $params['array_list'];//employeee lst @@ -314,7 +324,7 @@ class sendMailNotification // $mail = "aadhavanvalli@gmail.com"; // if (isset($mail) && !empty($mail)) { - $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']]; + $wholeData[] = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to']]; // } return $wholeData; @@ -491,7 +501,7 @@ class sendMailNotification $full_name = $value['first_name'] .' ' .$value['last_name']; $mail_content = str_replace("[[member_name]]", $full_name , $mail_content); - $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content]; + $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to']]; // $wholeData[] = ['mail' => $value['email'], 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']]; } return $wholeData; @@ -667,7 +677,7 @@ class sendMailNotification $mail_array = array_map('trim', $mail_array); $wholeData = []; foreach ($mail_array as $key => $value) { - $wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content]; + $wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content, 'reply_to' => $client_data['reply_to']]; // $wholeData[] = ['mail' => $value, 'subject' => $subject,'message'=> $mail_content, 'bcc'=> $client_data['common_mails']]; } diff --git a/app/Models/ClientModel.php b/app/Models/ClientModel.php index ce5481d3..4e05f84a 100755 --- a/app/Models/ClientModel.php +++ b/app/Models/ClientModel.php @@ -37,6 +37,7 @@ class ClientModel extends Model "reference", "phone", "email", + "reply_to", ];