我在 Drupal 中使用 mimemail 模块发送带有附件的电子邮件。电子邮件已正确发送,但附件未正确发送。这是我使用的代码(我刚刚启用了模块):
$sender = 'mycompany@company.com';
$recipient = 'myemail@mail.com';
$subject = 'New order';
$body = 'Please, see the attachment.';
$plaintext = TRUE;
$headers = array();
$attachments[]=array(
'filepath' => 'invoices/sample.pdf',
'filemime' => 'application/pdf',
);
mimemail($sender, $recipient, $subject, $body, $plaintext, $headers, $text = NULL, $attachments, $mailkey);
为了确保 pdf 附件的路径正确,我编写了这一行来从浏览器下载附件并且它可以工作。
header('Location: invoices/sample.pdf');
另外,我已经尝试过这个替代代码。但是还是什么都没有……
$file = new stdClass();
$file->filename = 'sample.pdf';
$file->filepath = 'invoices/sample.pdf';
$file->filemime = 'application/pdf';
mimemail($sender, $recipient, $subject, $body, $plaintext, $headers, $text = NULL, array($file), $mailkey);
附言。我不这么认为,但可能是因为我的主机不允许发送附件?谢谢