2010-07-18 46 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