Is it just me or is there almost no documentation on how to do this? Mandrill's site isn't much help. Anyway...here's the problem...
try {
$mandrill = new Mandrill('API_KEY');
$attachment = file_get_contents("../template.xls");
$attachment_encoded = base64_encode($attachment);
$message = array(
'html' => '<p>Some html text</p>',
'text' => 'Some text',
'subject' => 'Subject',
'from_email' => 'email@domain.com',
'from_name' => 'Name',
'to' => array(
array(
'email' => 'myemail@domain.com',
'name' => 'Name',
'type' => 'to'
)
),
'attachments' => array(
array(
'type' => 'application/vnd.ms-excel',
'name' => 'New_Features_Submission.xls',
'path' => $attachment_encoded
)
)
);
$async = false;
$result = $mandrill->messages->send($message, $async);
print_r($result);
} catch (Mandrill_Error $e) {
echo 'A Mandrill error occured: ' . get_class($e) . '-' . $e->getMessage();
throw $e;
}
The email sends correctly, but I can't even open the .xls file. I tried using 'application/xls' for the type, that didn't work either. I'm not familiar with encoding, help please!