Zeptomail API (PHP) with invoice pdf attachment
I am unable to properly make the syntax of API request via PHP to sent order invoice (PDF) in attachment.
Below is my sample code API request -
- $file = '169242759486.pdf';
- $attFile = 'https://www.example.com/secureInvoice/' . $file;
- $base64_attFile = chunk_split(base64_encode(file_get_contents($attFile)));
- "from": { "address": "sender@email.com", "name": "Sender Name"},
- "to": [{"email_address": {"address": "customer@email.com","name": "Customer Name"}}],
- "reply_to": {"address": "user@email.com", "name": "User Name"},
- "subject":"Test Email",
- "attachments": { "content": "'.$base64_attFile.' ", "mime_type": "application/pdf", "name": "myinvoice.pdf"},
- "htmlbody":"<div><b> Test email sent successfully. </b></div>",
- }'
I am getting the error response as -
- {"error":{"code":"TM_3301","details":[{"code":"SM_101","message":"Invalid value format","target":"attachments"}],"message":"Bad Syntax"}}
Anybody kindly help me to fix it.