diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index f8614ce..c1722ad 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -1662,6 +1662,9 @@ class MasterController extends AdminController } public function testZeptoSMTP() { + + echo "Inside the testZeptoSMTP function"; + $message = '

Request for Quotation (RFQ)

Dear {{RECIPIENT_NAME}},

We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.

RFQ Details

Client name{{CLIENT_NAME}}
Coverage Type{{POLICY_LONG_NAME}}
Policy Start Date{{POLICY_START_DATE}}
Policy Duration{{DURATION}}
Please note: Additional terms and details are included in the attachment for your reference.

Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.

Best regards,

Nhance India Pvt Ltd

'; $attachments = [ ["filePath" => ROOTPATH."public/sample_excel/sample_addition.xls","fileName" => "sample_addition.xls"], @@ -1670,9 +1673,14 @@ class MasterController extends AdminController ]; $email_id = 'srinivas.saravanan@venbainfotech.com'; $common = ['mail_type'=>'test_mail_cli']; + $bcc = 'venkateshraman786@gmail.com, srinivassaravanan2002@gmail.com, venkatesh.r@venbainfotech.com'; + $cc = 'gowtham.manavalan.la@gmail.com, venkatraj.office@gmail.com'; + + // print_r($bcc);die(); + // Send email and get response - $result = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments,'common'=>$common]); - + $result = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message, 'bcc'=>$bcc, 'cc'=>$cc, 'attachments' => $attachments,'common'=>$common]); + print_r($result); log_message('error',json_encode($result)); // Format the response for display/debugging diff --git a/app/Helpers/MailHelper.php b/app/Helpers/MailHelper.php index 87f25cc..adcbf2c 100755 --- a/app/Helpers/MailHelper.php +++ b/app/Helpers/MailHelper.php @@ -318,33 +318,34 @@ class MailHelper 'htmlbody' => $message ]; + // Add CC recipients if provided if (!empty($cc)) { - $postData['cc'] = []; - // Handle both string and array inputs for CC - $ccEmails = is_array($cc) ? $cc : [$cc]; - foreach ($ccEmails as $ccEmail) { - $postData['cc'][] = [ + $ccList = explode(',', $cc); + $ccList = array_map('trim', $ccList); + $postData['cc'] = array_map(function ($email) { + return [ 'email_address' => [ - 'address' => $ccEmail + 'address' => $email ] ]; - } + }, $ccList); } - // Add BCC recipients if provided + + // Add BCC if present if (!empty($bcc)) { - $postData['bcc'] = []; - // Handle both string and array inputs for BCC - $bccEmails = is_array($bcc) ? $bcc : [$bcc]; - foreach ($bccEmails as $bccEmail) { - $postData['bcc'][] = [ + $bccList = explode(',', $bcc); + $bccList = array_map('trim', $bccList); + $postData['bcc'] = array_map(function ($email) { + return [ 'email_address' => [ - 'address' => $bccEmail + 'address' => $email ] ]; - } + }, $bccList); } + // // Handle attachments if (!empty($attachments)) {