wordoress插件Easy WP SMTP发送邮件服务

轩陌

分类: WordPress 4973 12

当我们用wordpress的时候,用户评论我们的文章,回复用户的评论,如果没有邮件通知,就只能登录到后台才能看见,有时候不登录都不知道自己的文章有人来评论了,这时候就可以借助这个插件来做这个事情,下边是配置步骤:

第一步先在后台安装插件:

 

第二步配置邮件发件服务器:

 

 

拿QQ邮箱设置为例:

 

 

 

第三步测试配置是否成功:

 

第四步将邮件发送代码添加到主题的functions.php这个文件里面(转自露兜,原文地址:Go>>):


/*
 ****************************************
 * 邮件回复功能
 ****************************************
 */
function ludou_comment_mail_notify($comment_id, $comment_status) {
	  // 评论必须经过审核才会发送通知邮件
    if ($comment_status !== 'approve' && $comment_status !== 1)
        return;
    $comment = get_comment($comment_id);
    if ($comment->comment_parent != '0') {
        $parent_comment = get_comment($comment->comment_parent);
	    // 邮件接收者email
        $to = trim($parent_comment->comment_author_email);
	    // 邮件标题
        $subject = '您在[' . get_option("blogname") . ']的留言有了新的回复';
	    // 邮件内容,自行修改,支持HTML
        $message = '
	      

Hi, ' . $parent_comment->comment_author . '

您之前在《' . get_the_title($comment->comment_post_ID) . '》的留言:
' . $parent_comment->comment_content . '

' . $comment->comment_author . ' 给您回复:
' . $comment->comment_content . '

您可以 点此查看回复完整內容

欢迎再度光临 ' . get_option('blogname') . '

(此邮件由系统自动发送,请勿回复)

'; $message_headers = "Content-Type: text/html; charset=\"" . get_option('blog_charset') . "\"\n"; // 不用给不填email的评论者和管理员发提醒邮件 if ($to != '' && $to != get_bloginfo('admin_email')) @wp_mail($to, $subject, $message, $message_headers); } } // 编辑和管理员的回复直接发送提醒邮件,因为编辑和管理员的评论不需要审核 add_action('comment_post', 'ludou_comment_mail_notify', 20, 2); // 普通访客发表的评论,等博主审核后再发送提醒邮件 add_action('wp_set_comment_status', 'ludou_comment_mail_notify', 20, 2);
  • 15人 Love
  • 0人 Haha
  • 1人 Wow
  • 0人 Sad
  • 1人 Angry
Easy WP SMTP、wordpress发送邮件

作者简介: 轩陌

打赏

生命的意义在于折腾,一直努力成长中,期待梦想实现的那刻。

共 12 条评论关于 “wordoress插件Easy WP SMTP发送邮件服务”

Loading...