直接在邮箱回复的代码后面添加一段代码即可:
(########################################################## 之间的内容为新添加. )
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | <?php /* comment_mail_notify v1.0 by willin kan. (有勾選欄, 由訪客決定) */ function comment_mail_notify($comment_id) { $admin_notify = '0'; // admin 要不要收回覆通知 ( '1'=要 ; '0'=不要 ) $admin_email = get_bloginfo ('admin_email'); // $admin_email 可改為你指定的 e-mail. $comment = get_comment($comment_id); $comment_author_email = trim($comment->comment_author_email); $parent_id = $comment->comment_parent ? $comment->comment_parent : ''; global $wpdb; if ($wpdb->query("Describe {$wpdb->comments} comment_mail_notify") == '') $wpdb->query("ALTER TABLE {$wpdb->comments} ADD COLUMN comment_mail_notify TINYINT NOT NULL DEFAULT 0;"); if (($comment_author_email != $admin_email && isset($_POST['comment_mail_notify'])) || ($comment_author_email == $admin_email && $admin_notify == '1')) $wpdb->query("UPDATE {$wpdb->comments} SET comment_mail_notify='1' WHERE comment_ID='$comment_id'"); $notify = $parent_id ? get_comment($parent_id)->comment_mail_notify : '0'; $spam_confirmed = $comment->comment_approved; if ($parent_id != '' && $spam_confirmed != 'spam' && $notify == '1') { $wp_email = 'no-reply@' . preg_replace('#^www\.#', '', strtolower($_SERVER['HTTP_HOST'])); // e-mail 發出點, no-reply 可改為可用的 e-mail. $to = trim(get_comment($parent_id)->comment_author_email); $subject = '您在 [' . get_option("blogname") . '] 的留言有了新回复'; $message = ' <div style="background-color:#eef2fa; border:1px solid #d8e3e8; color:#111; padding:0 15px; -moz-border-radius:5px; -webkit-border-radius:5px; -khtml-border-radius:5px;"> <p>' . trim(get_comment($parent_id)->comment_author) . ', 您好!</p> <p>您曾在《' . get_the_title($comment->comment_post_ID) . '》的留言:<br /> ' . trim(get_comment($parent_id)->comment_content) . '</p> <p>' . trim($comment->comment_author) . ' 给您的回复:<br /> ' . trim($comment->comment_content) . '<br /></p> <p>您可以点击 <a href="' . htmlspecialchars(get_comment_link($parent_id)) . '"> 查看完整回复內容</a></p> <p>欢迎再度光临 <a href="' . get_option('home') . '">' . get_option('blogname') . '</a></p> <p>(此邮件由系统自动发出, 请勿回复.)</p> </div>'; $from = "From: \"" . get_option('blogname') . "\" <$wp_email>"; $headers = "$from\nContent-Type: text/html; charset=" . get_option('blog_charset') . "\n"; @wp_mail( $to, $subject, $message, $headers ); //echo 'mail to ', $to, '<br/> ' , $subject, $message; // for testing } //发信到139邮箱 ########################################################## if($admin_email != $comment_author_email ) { $to='你的139邮箱账号(如xxx@139.com)'; $from = "From: \"" . get_option('blogname') . "\" <$admin_email>"; $subject = trim($comment->comment_author) .'在 [' . get_the_title($comment->comment_post_ID) . '] 留言:'; $message =trim($comment->comment_content); $headers = "$from\nContent-Type: text/html; charset=" . get_option('blog_charset') . "\n"; @wp_mail( $to, $subject, $message, $headers ); } ########################################################## } add_action('comment_post', 'comment_mail_notify'); /* 自動加勾選欄 */ function add_checkbox() { echo '<input style="margin-left:20px;width:20px;" type="checkbox" name="comment_mail_notify" id="comment_mail_notify" value="comment_mail_notify" checked="checked" /><label for="comment_mail_notify">有人回复时邮件通知我</label>'; } add_action('comment_form', 'add_checkbox'); // -- END ---------------------------------------- |
然后就是到 139 邮箱里面去设置一下喽:
先把我们自己的邮箱加入白名单,以免被当垃圾邮件:
http://mail.10086.cn/
新建邮件分拣规则,让从博客发来的邮件自动分类到我们新建的文件夹:
喜欢这篇文章吗?
请订阅本站 RSS feed 或




12:49 上午, 2011年12月29日iShare /
这样搞留言有点疯狂了,除非有很重要的留言要等
9:07 下午, 2010年11月3日PAUL /
这个方法很绝,不过有邮件通知就够用了。。。
8:40 下午, 2010年10月20日IT不倒翁 /
恩,确实很方便,但是我很烦手机。我手机都不和网站挂钩的
2:07 下午, 2010年10月3日Vinceen /
用过,挺方便,但会出岔子
1:05 下午, 2010年09月18日julor-学习啦 /
我也是用这个的,但是后台回复评论的时候提交需要很长时间,然后返回错误,可以收到邮件,不知为什么。
5:47 下午, 2010年09月12日小王子 /
以前用过,但是后来都没用了,有时候短信还有乱码。
4:24 下午, 2010年09月10日baby_1224 /
4:43 下午, 2010年09月10日荒野无灯 /
我这一般留言不是很多喽。
11:48 上午, 2010年09月5日久酷 /
天……如果每条留言都短信通知,留言多一些的,手机就不会停了,24小时持续工作了
10:21 上午, 2010年09月4日mybg /
站长能否研究下Typecho,地址是
http://ihacklog.com/gogogo/aHR0cDovL3R5cGVjaG8ub3JnLw==
写点这类的文章呢
4:17 下午, 2010年09月3日起衣 /
是通过139邮箱么。
直接通过飞信接口的。。恩。。荒野快折腾出来
4:19 下午, 2010年09月3日荒野无灯 /
没有用飞信接口.以前有个用飞信接口的插件,不过现在飞信接口改了,貌似没公布.这里用的是139邮箱的功能.