我已经使用内容类型创建了一个表单,并创建了一个具有以下代码的自定义模块,用于在表单提交后向管理员发送电子邮件通知。在表格提交后向管理员发送电子邮件通知
<?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