你能帮我写这个代码保存它后发送节点这个节点有一个附件可能是pdf doc和docx我用过这个钩子这可以发送一个带有html附件的空邮件包含邮件正文而不是文件内容
function footer_node_insert($node){
if($node->type=="application_form"){
$file_data=file_load($node->field_cv['und'][0]['fid']);
$filemime=$file_data->filemime;
$filename=$file_data->filename;
$file_uri=file_create_url($file_data->uri);
$job=node_load($node->field_apply['und'][0]['nid']);
$to='mail@mail.com';
$key = "notice";
$module = 'footer';
$message = drupal_mail($module, $key, $to, language_default(), array(), "from@froom.com", True);
// Build the default headers
$headers = array(
'MIME-Version' => '1.0',
'Content-Type' => 'text/html; charset=UTF-8; format=flowed; delsp=yes',
'Content-Transfer-Encoding' => '8Bit',
'X-Mailer' => 'Drupal',
);
$attachment = array(
'filecontent' => file_get_contents($file_uri),
'filename' =>$filename,
'filemime' =>$filemime
);
$message['headers']['Content-Type'] = $headers ;
$message['subject'] = 'Apply for ' .$job->title . ' Page';
$body = array();
$body[] = '<b>'. t('Name:').'</b>'.$node->title;
$body[] = '<b>'. t('Email:').'</b>'.$node->field_application_email['und']['0']['email'] ;
$body[] = '<b>'. t('Current Job:').'</b>'.$node->field_current_job['und']['0']['value'];
$body[] = '<b>'. t('Current Company:').'</b>'.$node->field_current_company['und']['0']['value'];
$body[] = '<b>'. t('Home Phone:').'</b>'.$node->field_home_phone['und']['0']['value'];
$body[] = '<b>'. t('Mobile Phone:').'</b>'.$node->field_mobile_phone['und']['0']['value'];
$message['body'] = implode('<br>', $body);
$message['params']['attachments'][] = $attachment;
// Retrieve the responsible implementation for this message.
$system = drupal_mail_system($module, $key);
// Format the message body.
// $message = $system->format($message);
// Send e-mail.
$message['result'] = $system->mail($message);
if ($message['result']) {
echo 'true';
} else {
echo 'false';
}
exit();
}
}