MimeMail:附件问题

时间:2010-07-18 17:40:23

标签: php drupal drupal-6 mime-mail

我在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);

PS。我不这么认为,但也许是因为我的托管不允许发送附件? 感谢

1 个答案:

答案 0 :(得分:0)

为Mime Mail模块打开了两个问题报告。

Attachments specified with absolute local paths are not added中,OP报告使用绝对路径指定的附件不起作用;有一个提议的补丁来解决这个问题。在该问题中,建议更改代码以发送带有附件的电子邮件

header('Location: invoices/sample.pdf');

$sender = 'mycompany@company.com';
$recipient = 'myemail@email.com';
$subject = 'New order';
$body = 'Please, see the attachment.';
$plaintext = TRUE;
$headers = array();
$attachments[] = array(
  'filepath' => 'invoices/sample.pdf',
  'filemime' => 'mime/type',
);

mimemail($sender, $recipient, $subject, $body, $plaintext, $headers, $text = NULL, $attachments, $mailkey);

header('Location: invoices/sample.pdf');

$sender = 'mycompany@company.com';
$recipient = 'myemail@email.com';
$subject = 'New order';
$body = 'Please, see the attachment.';
$plaintext = TRUE;
$headers = array();
$attachments[] = array(
  'filepath' => 'invoices/sample.pdf',
  'filemime' => 'mime/type',
  'filename' => 'sample.pdf',
  'list' => TRUE,
);

mimemail($sender, $recipient, $subject, $body, $plaintext, $headers, $text = NULL, $attachments, $mailkey);

mimemail + smtp + attachments not working with attachments中,OP报告使用SMTP时未显示附件;在同一报告中,另一个用户报告他没有使用SMTP,但是当通过规则发送电子邮件时,附件不会显示。

相关问题