2010-07-18 40 views
1

我在Drupal中使用mimemail模块发送附件的电子邮件。电子邮件正确发送,但附件不正确。这是我使用的代码(我刚刚启用的模块):MimeMail:与附件问题

$sender = '[email protected]'; 
$recipient = '[email protected]'; 
$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。我不这么认为,但也许是因为我的主机不允许发送附件? 谢谢

+0

您是否尝试过使用绝对文件路径而不是'invoices/sample.pdf'? – 2010-07-18 17:46:23

+0

是的,我已经尝试了所有可能的路径...我的网站/发票的根...也是完整的一个http://www.domain.com/invoices ...是$附件很好地声明和传递给milemail功能?我真的被困在这,argh – aneuryzm 2010-07-18 20:35:51

回答

0

有两个Mime Mail模块打开的问题报告。

Attachments specified with absolute local paths are not added中,OP报告使用绝对路径指定的附件不起作用;有一个建议的补丁来解决这个问题。在这个问题时,建议更改代码与附着物从

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

$sender = '[email protected]'; 
$recipient = '[email protected]'; 
$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 = '[email protected]'; 
$recipient = '[email protected]'; 
$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,但是当通过规则发送电子邮件时,附件不会显示。

+0

在drupal中调用的正确的函数,和'header()'有相同的效果,是'drupal_set_header()',它将设置的头文件存储在一个静态变量中,并返回已经设置的标题。 – kiamlaluno 2010-07-20 14:54:40

+0

太棒了,最后,它工作。 – aneuryzm 2010-07-20 15:34:26