还是利用函数function.php文件实现。
添加:
//comment_mail_notify function comment_mail_notify($comment_id) { $comment = get_comment($comment_id); $parent_id = $comment->comment_parent ? $comment->comment_parent : ''; $spam_confirmed = $comment->comment_approved; if (($parent_id != '') && ($spam_confirmed != 'spam')) { $wp_email = 'no-reply@' . preg_replace('#^www.#', '', strtolower($_SERVER['SERVER_NAME']));//发件人e-mail地址 $to = trim(get_comment($parent_id)->comment_author_email); $subject = '您在['.get_option("blogname").']的留言有了回复'; $message = '
‘.trim(get_comment($parent_id)->comment_author).’, 您好!
这是您在《’.get_the_title($comment->comment_post_ID).’》中的留言:
‘ .trim(get_comment($parent_id)->comment_content).’
以下是’.trim($comment->comment_author).’ 给您的回复:
‘ .trim($comment->comment_content).’
‘ . get_option(‘blogname’) . ‘内容已经更新,欢迎再度光临!
此邮件为系统发出,请勿回复此邮件!
任何疑问,欢迎邮件admin@luoxufeiyan.com
‘; $from = “From: “” . get_option(‘blogname’) . “” <$wp_email>”; $headers = “$fromnContent-Type: text/html; charset=” . get_option(‘blog_charset’) . “n”; wp_mail( $to, $subject, $message, $headers ); //echo ‘mail to ‘, $to, ‘
‘ , $subject, $message; // for testing } } add_action(‘comment_post’, ‘comment_mail_notify’); //comment_mail_notify end
即可。
参考自:wordpress 3.8 不使用插件,实现email通知访客其评论有人回复——老牛博客