我已經使用內容類型創建了一個表單,並創建了一個具有以下代碼的自定義模塊,用於在表單提交後向管理員發送電子郵件通知。在表格提交後向管理員發送電子郵件通知
<?php
$params = array(
'subject' => "New submission",
'body' => "<p>Hello world</p>",
);
//send out the e-mail,
drupal_mail('admin_email_notification', 'admin_email_notification_example', "[email protected]", language_default(), $params);
drupal_set_message("Sent e-mail to [email protected]");
/** Implementing the hook_mail()**/
function admin_email_notification_mail($key, &$message, $params)
{
//Grab the subject and body from params and add it to the messsage.
$message['subject'] = $params['subject'];
$message['body'][] = $params['body'];
switch($key)
{
case "admin_email_notification_example":
break;
}
}
function admin_email_notification_FORM_ID_alter(&$form, &$form_state, $form_id)
{
t($form['#submit'], 'admin_email_notification_custom_submission');
}
function admin_email_notification_custom_submission(&$form, $form_state)
{
$params = array(
'subject' => "New submission",
'body' => "<p>Hello world</p>",
);
//send out the e-mail,
drupal_mail('admin_email_notification', 'admin_email_notification_example', "[email protected]", language_default(), $params);
drupal_set_message("Sent e-mail to [email protected]");
}
對於模塊的工作,我不得不在commet線mail.inc 413,因爲我是在....../drupal_folder /包括/ mail.inc接收()的錯誤消息,調用未定義功能_filter_htmlcorrector。管理員正在收到表格提交後收到的電子郵件。 但問題是,即使在任何類型的行動後,例如管理員正在接收電子郵件的頁面重新壓縮。 有沒有一種方法可以用來在代碼中包含一個規則,如果表單已經提交,那麼該規則只會設置發送郵件給管理員的限制。而且我還希望模塊能夠很好地工作,而無需評論mail.inc中包含_filter_htmlcorrector()的行。
呼叫您的形式drupal_mail功能提交處理:) – Elendas
謝謝,但我怎麼做, – Tanah
採取看看我的評論下面 – Elendas