FIX_ZEPTO_MAIL_BCC_CC_NOT_SEND_ISSUE_SRINIVAS
This commit is contained in:
parent
7f7dee16b0
commit
a2ccebf83e
@ -194,6 +194,11 @@ class MailHelper
|
||||
} else {
|
||||
$bcc = '';
|
||||
}
|
||||
if(isset($params['cc'])){
|
||||
$cc = $params['cc'];
|
||||
}else{
|
||||
$cc = '';
|
||||
}
|
||||
$from_address = getenv('email.fromEmail');
|
||||
|
||||
|
||||
@ -255,7 +260,7 @@ class MailHelper
|
||||
}
|
||||
|
||||
$apiResponse = json_decode($response, true);
|
||||
|
||||
log_message('error',$apiResponse);
|
||||
if ($httpCode === 200) {
|
||||
return json_encode(['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...', 'data' => $emaill], 200);
|
||||
} else {
|
||||
@ -297,6 +302,8 @@ class MailHelper
|
||||
$message = $params['message'];
|
||||
$attachments = isset($params['attachments']) ? $params['attachments'] : [];
|
||||
$common = isset($params['common']) ? $params['common'] : '';
|
||||
$bcc = isset($params['bcc']) ? $params['bcc'] : '';
|
||||
$cc = isset($params['cc']) ? $params['cc'] : '';
|
||||
|
||||
$from_address = getenv('email.fromEmail');
|
||||
try {
|
||||
@ -317,6 +324,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'][] = [
|
||||
'email_address' => [
|
||||
'address' => $ccEmail
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Add BCC recipients if provided
|
||||
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'][] = [
|
||||
'email_address' => [
|
||||
'address' => $bccEmail
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Handle attachments
|
||||
if (!empty($attachments)) {
|
||||
$postData['attachments'] = [];
|
||||
@ -328,13 +363,12 @@ class MailHelper
|
||||
$postData['attachments'][] = [
|
||||
'content' => base64_encode(file_get_contents($attachment['filePath'])),
|
||||
'name' => $attachment['fileName'],
|
||||
'mime_type' => $fileMimeType, // Add mime_type field
|
||||
'mime_type' => $fileMimeType,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => "https://api.zeptomail.in/v1.1/email",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
@ -355,12 +389,12 @@ class MailHelper
|
||||
$mail_result = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
curl_close($curl);
|
||||
// log_message('error','inside mail helper');
|
||||
// log_message('error', $response.' error->'.$err);die();
|
||||
|
||||
$res['params'] = $params;
|
||||
$MailDataHelper = new GmailResponseHandler();
|
||||
$apiResponse = json_decode($mail_result, true);
|
||||
$res['zepto_api'] = $apiResponse;
|
||||
|
||||
if (isset($apiResponse['error'])) {
|
||||
$response = $res;
|
||||
$MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
@ -372,9 +406,6 @@ class MailHelper
|
||||
], 404);
|
||||
}
|
||||
|
||||
// $apiResponse = json_decode($response, true);
|
||||
|
||||
// Check if request_id exists in response (indicates success)
|
||||
if (isset($apiResponse['data'])) {
|
||||
$response = $res;
|
||||
$MailDataHelper->receive_and_distribute_param_to_functions($response);
|
||||
@ -398,7 +429,6 @@ class MailHelper
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public static function bulk_mail(array $mails = [])
|
||||
{
|
||||
$model = new JobModel();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user