2016-04-13 11 views
0

添付ファイルに何か問題が見つかりません。電子メールは空に送信されます。 これは、drupal 7のカスタマイズされたWebフォーム用です。ここに私のコードです:Drupalのメールアドレスは空です。添付ファイルに何が問題なのですか?

<?php 

module_load_include('inc', 'print_pdf', 'print_pdf.pages'); 
$file_content = module_invoke('print_pdf', 'generate_path', '/****.pdf'); 

$attachment = array(
'filecontent' => $file_content, 
'filename' => '****.pdf', 
'filemime' => 'application/pdf', 
'list' => TRUE 
); 

$message = array(
'headers' => array('Content-Type' => 'text/html'), 
'key' => 'test', 
'to' => '****@****.com', 
'from' => '****@****.com', 
'attachments' => $attachments, 
'subject' => 'Test email', 
'body' => 'test' 
); 

$system = drupal_mail_system('mimemail', 'test'); 
$system->format($message); 
$result = $system->mail($message); 

?> 

答えて

0

ファイルへのパスとアクセスを確認してください。

私はMimemailとMailSystemと添付ファイルとして管理されていないファイルを送信するには、このコードを使用します。

/** 
* Send email with attachment 
*/ 
mymodule_send('default', array(
     'params' => array(
     'subject' => 'Mail suject', 
     'body' => '<p>Mail body</p>', 
     'attachments' => array(
      array(
      'filename' => 'HumanreadableFileName.xls', 
      'filemime' => 'application/vnd.ms-excel', // xls mime 
      'filepath' => 'public://2016-04-18_report.xls', // path to file 
     ), 
     ), 
    ), 
    ), '[email protected]'); 

/** 
* Implements hook_send(). 
*/ 
function mymodule_send($key, $params = array(), $to = NULL, $from = NULL) { 

    if (!valid_email_address($to)) { 
    $to = variable_get('site_mail', ini_get('sendmail_from')); 
    } 

    drupal_mail('snabmail', $key, $to, language_default(), $params, $from); 
} 
関連する問題