Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Drupal 7 Drupal 7-向用户发送关于内容修改的电子邮件_Drupal 7_Drupal Webform_Drupal Rules - Fatal编程技术网

Drupal 7 Drupal 7-向用户发送关于内容修改的电子邮件

Drupal 7 Drupal 7-向用户发送关于内容修改的电子邮件,drupal-7,drupal-webform,drupal-rules,Drupal 7,Drupal Webform,Drupal Rules,我有一个webform页面,用户在其中提交查询。提交表单时,将向用户和管理员发送确认邮件。我已经安装了模块,通过该模块,用户和管理员都可以在表单中评论和更改状态,现在我想向管理员和用户发送关于每个评论和状态更改的邮件 我已经尝试使用该模块,但它不起作用。模块未发送邮件 是否有其他方式或模块可用于向用户发送邮件 网络表单版本7.x-4.15 提前感谢:)您可以在自定义表单中使用hook\u webform\u submission\u update发送电子邮件,也可以使用action和triger

我有一个webform页面,用户在其中提交查询。提交表单时,将向用户和管理员发送确认邮件。我已经安装了模块,通过该模块,用户和管理员都可以在表单中评论和更改状态,现在我想向管理员和用户发送关于每个评论和状态更改的邮件

我已经尝试使用该模块,但它不起作用。模块未发送邮件

是否有其他方式或模块可用于向用户发送邮件

网络表单版本7.x-4.15


提前感谢:)

您可以在自定义表单中使用hook\u webform\u submission\u update发送电子邮件,也可以使用action和triger发送电子邮件

  • 为此,您必须添加新的自定义模块,您可以参考此链接:-

  • 在custom.module文件中添加此代码

  • 请参阅此代码

     function <moduleName>_webform_submission_update($node, $submission)
            {
                            // you can send mail like this
                            $message = 'New signup email address'; // Body of your email here. 
                            //you can also set any form detail using $node,$submission variable
                            $params = array(
                                   'body' => $message,
                                   'subject' => 'Website Information Request',
                                   'headers'=>'simple',
                             );
                             $to = "Your Email Address";
                            drupal_mail('contactform', 'send_link', $to, language_default(), $params, 'demo@demo.com', TRUE);
    
             }
    
    功能\u网络表单\u提交\u更新($node,$submission)
    {
    //你可以像这样发送邮件
    $message='新注册电子邮件地址';//此处是您的电子邮件正文。
    //还可以使用$node、$submission变量设置任何表单详细信息
    $params=数组(
    “body”=>$message,
    “主题”=>“网站信息请求”,
    'headers'=>'simple',
    );
    $to=“您的电子邮件地址”;
    drupal_mail('contactform','send_link',$to,language_default(),$params,'demo@demo.com",对),;
    }
    
    我通过在模块中插入hook\u邮件代码解决了上述问题

    如果其他人也面临同样的问题,这里是我在custom_webform_comments.module文件中插入的代码

    /**
    *实现hook_mail()。
    */
    函数自定义\网络表单\评论\邮件($key,&$message,$params){
    交换机($key){
    案例“自定义网页表单评论电子邮件”:
    $message['subject']=t('Submit Request Form update');
    $message['body'][]=t('您在提交的表单上获得了新的注释和状态更新'),数组('@site name'=>variable_get('site_name','example.com');
    $message['body'][]=t(变量_get('custom_webform_comments_email_text','');
    打破
    }
    }
    
    在上述代码行之后,将以下代码放在数据库之后,在函数custom_webform_comments_commentform_submit()中插入查询,以便在每次注释更新后发送邮件

    函数自定义\网络表单\注释\注释表单\提交($form,$form\ state){
    $fv=$form_state['values'];
    $insert1=db\u insert('custom\u webform\u comments')
    ->字段(数组)(
    'cid'=>NULL,
    'comment'=>$fv['addnew']['comment'],
    'subject'=>$fv['addnew']['subject'],
    'nid'=>$fv['addnew']['nid'],
    'sid'=>$fv['addnew']['sid'],
    'commenter\u user\u id'=>$fv['addnew']['commenter\u user\u id'],
    'comment_parent'=>'0',
    'ts'=>日期(“Y-m-d H:i:s”)
    ))->执行();
    如果($insert1)
    {
    全球$用户;
    $params=数组(
    “body”=>$message,
    “主题”=>“网站信息请求”,
    'headers'=>'simple',
    );
    $message=drupal\u mail('custom\u webform\u comments','custom\u webform\u comments\u email',$user->mail,language\u default(),$params,'test@example.com",对),;
    如果(!empty($message['result'])){
    watchdog('mail','mail已成功发送(从%from到%to)以进行评论更新',数组('%from'=>$message['from'],'%to'=>$message['to']),watchdog\u通知);
    //drupal_设置_消息(“邮件已发送!”);
    }
    否则{
    watchdog('mail','Error sending e-mail(从%from到%to.),数组('%from'=>$message['from'],'%to'=>$message['to']),watchdog\u Error);
    drupal_set_消息(t(“无法发送电子邮件。如果问题仍然存在,请与站点管理员联系”),“错误”);
    }
    }
    返回$insert1;
    }
    
    类似地,要在每次状态更新时获取邮件,请更新以下函数

    函数自定义\网络表单\注释\状态\数据库更新程序($data){
    全球$用户;
    //将值插入数据库
    $insert=db\U insert('custom\u webform\u submission\u status')
    ->字段(数组)(
    'id'=>NULL,
    'status'=>$data['status'],
    “提交时间”=>日期(“Y-m-d H:i:s”),
    'nid'=>$data['nid'],
    'sid'=>$data['sid'],
    'user'=>序列化($user)
    ))->执行();
    如果($插入)
    {
    全球$用户;
    $params=数组(
    “body”=>$message,
    “主题”=>“网站信息请求”,
    'headers'=>'simple',
    );
    $message=drupal\u mail('custom\u webform\u comments','custom\u webform\u comments\u email',$user->mail,language\u default(),$params,'test@example.com",对),;
    如果(!empty($message['result'])){
    watchdog('mail','mail已成功发送(从%from到%to)以进行状态更新',数组('%from'=>$message['from'],'%to'=>$message['to']),watchdog\u通知);
    //drupal_设置_消息(“邮件已发送!”);
    }
    否则{
    watchdog('mail','Error sending e-mail(从%from到%to.),数组('%from'=>$message['from'],'%to'=>$message['to']),watchdog\u Error);
    drupal_set_消息(t(“无法发送电子邮件。如果问题仍然存在,请与站点管理员联系”),“错误”);
    }
    }
    返回$insert;
    }
    
    谢谢您的回复……但请您详细说明一下,因为我是新来的。最好使用您自己的自定义模块,而不是编辑贡献的模块。在自定义模块更新时,您可能会遇到问题。