【发布时间】:2015-10-14 14:48:08
【问题描述】:
只有我一个人还是几乎没有关于如何做到这一点的文档? Mandrill 的网站没有多大帮助。不管怎样……问题来了……
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;
}
电子邮件发送正确,但我什至无法打开 .xls 文件。我尝试使用 'application/xls' 作为类型,但也没有用。我对编码不熟悉,请帮忙!
【问题讨论】: