我在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。我不这么认为,但也许是因为我的托管禁止发送附件? 谢谢

有帮助吗?

解决方案

MIME邮件模块打开了两个问题报告。

未添加绝对本地路径指定的附件,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 +附件不使用附件,op报告附件未显示使用SMTP时;在同一报告中,另一个用户报告他未使用SMTP,但通过规则发送电子邮件时未显示附件。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top