I am trying to add some attachments to an email that is being sent using the mandrill api via a php wrapper. I have tried a number of different things to try to successfully att
OK. So thanks to Kaitlin for her input. The PHP way to deal with this is to get the file and then base64_encode it:
$attachment = file_get_contents(WWW_ROOT.'files/downloads/file.pdf');
$attachment_encoded = base64_encode($attachment);
and then in the attachments part of the mandrill array you pass the :
"attachments" => array(
array(
'content' => $attachment_encoded,
'type' => "application/pdf",
'name' => 'file.pdf',
)
So easy! Thanks again Kaitlin!
It looks like you're passing a parameter called path
, but the Mandrill API doesn't take the path of a file for attachments. If you're using the send or send-template call, attachments should be an associative array (hash) with three keys: type, name, and content.
The content parameter should be the contents of the file as a Base64 encoded string, so instead of path, you'll want to get the file contents, Base64 encode them, and then pass them in a parameter called content
instead of path
.
You can see the full details of the parameters, including for attachments, in the Mandrill API docs here: https://mandrillapp.com/api/docs/messages.html#method=send