2016-04-13 4 views
0

Ich kann nicht finden, was mit dem Anhang falsch ist. Die E-Mail wird leer gesendet. Dies ist für drupal 7 angepasste Webform. Hier ist mein Code:Drupal E-Mail ist leer. Was stimmt nicht mit meiner Bindung?

<?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); 

?> 

Antwort

0

Versuchen Sie, den Pfad und den Zugriff auf die Datei zu überprüfen.

Ich benutze diesen Code nicht verwalteten Dateien als Anhänge mit Mimemail und Mailsystem zu senden:

/** 
* 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); 
} 
Verwandte Themen