N
Novu5w ago
D0808

email attachment issue in php code

i tried triggering email with an attachment with php code
$response = $novu->triggerEvent([
'name' => 'work-with-us-email',
'payload' => [
'fullName' => $arrData['full_name'],
'education' => $arrData['education'],
'experience' => $arrData['experience'],
'keySkills' => $arrData['key_skills'],
'previousEmployer' => $arrData['previous_employer'],
'position' => $jobPosition[0]['name'],
'phoneNo' => $arrData['phone'],
'emailName' => $arrData['email'],
'coverLetter' => $arrData['cover_letter'],
'url' => base_url(),
'attachments' => [
'file' => file_get_contents($arrEmailDetails['file_path']),
'name' => 'resume',
'mime' => 'application/octet-stream',
],
],

'to' => [
'subscriberId' => '670ca1e58b5274f54798ae1b',
'email' => $careersEmailId,
],
])->toArray();
$response = $novu->triggerEvent([
'name' => 'work-with-us-email',
'payload' => [
'fullName' => $arrData['full_name'],
'education' => $arrData['education'],
'experience' => $arrData['experience'],
'keySkills' => $arrData['key_skills'],
'previousEmployer' => $arrData['previous_employer'],
'position' => $jobPosition[0]['name'],
'phoneNo' => $arrData['phone'],
'emailName' => $arrData['email'],
'coverLetter' => $arrData['cover_letter'],
'url' => base_url(),
'attachments' => [
'file' => file_get_contents($arrEmailDetails['file_path']),
'name' => 'resume',
'mime' => 'application/octet-stream',
],
],

'to' => [
'subscriberId' => '670ca1e58b5274f54798ae1b',
'email' => $careersEmailId,
],
])->toArray();
and it does send a successful sent message
(
[transactionId] => 9434179b-b539-42fc-a94f-756e86db38d4
[acknowledged] => 1
[status] => processed
)
(
[transactionId] => 9434179b-b539-42fc-a94f-756e86db38d4
[acknowledged] => 1
[status] => processed
)
but mail does not get received. this code of php i typed on my own by reference of nodejs code. there was no specific syntax for php. can any one help me with it?
1 Reply
Pawan Jain
Pawan Jain4w ago
@D0808 As per our logs, I see this error
Could not establish tunnel connection for `https://84b17185-bd5f-4c85-b3ce-ec9f042509a7.novu.sh/api/novu?action=execute&workflowId=work-with-us-email&stepId=send-email`. Error: `Could not connect to your dev server. Make sure you are running the `npx novu@latest dev` command`
Could not establish tunnel connection for `https://84b17185-bd5f-4c85-b3ce-ec9f042509a7.novu.sh/api/novu?action=execute&workflowId=work-with-us-email&stepId=send-email`. Error: `Could not connect to your dev server. Make sure you are running the `npx novu@latest dev` command`
On high level your code implementation looks correct. I have few questions: 1. We support base64 and buffer format for file attachments. Are you sure you are sending file in this format? 2. As per above error, novu was unable to reach your tunnel url or bridge url. Can you check if tunnel is still running? You can close and restart using this command? npx novu@latest dev`` 3. What error you see in activity feed for this transactionid 9434179b-b539-42fc-a94f-756e86db38d4`?
Want results from more Discord servers?
Add your server