留言短信通知,何需插件?

直接在邮箱回复的代码后面添加一段代码即可:
(########################################################## 之间的内容为新添加. )

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)

  1. iShare  / 回复

    这样搞留言有点疯狂了,除非有很重要的留言要等

  2. PAUL  / 回复

    这个方法很绝,不过有邮件通知就够用了。。。

  3. IT不倒翁  / 回复

    恩,确实很方便,但是我很烦手机。我手机都不和网站挂钩的 :cool:

  4. Vinceen  / 回复

    用过,挺方便,但会出岔子

  5. julor-学习啦  / 回复

    我也是用这个的,但是后台回复评论的时候提交需要很长时间,然后返回错误,可以收到邮件,不知为什么。

  6. 小王子  / 回复

    以前用过,但是后来都没用了,有时候短信还有乱码。

  7. baby_1224  / 回复

    :???: 留言多的时候爪机悲剧勒…囧~

  8. 久酷  / 回复

    天……如果每条留言都短信通知,留言多一些的,手机就不会停了,24小时持续工作了 :shock: :shock:

  9. mybg  / 回复

    站长能否研究下Typecho,地址是
    http://ihacklog.com/gogogo/aHR0cDovL3R5cGVjaG8ub3JnLw==
    写点这类的文章呢

  10. 起衣  / 回复

    是通过139邮箱么。
    直接通过飞信接口的。。恩。。荒野快折腾出来

    • 荒野无灯  / 回复

      没有用飞信接口.以前有个用飞信接口的插件,不过现在飞信接口改了,貌似没公布.这里用的是139邮箱的功能.

发表评论 修改评论取消编辑

允许使用的标签 - 您可以在评论中使用如下的 HTML 标签以及属性。

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 :wink:  :-|  :-x  :twisted:  :)  8-O  :(  :roll:  :-P  :oops:  :-o  :mrgreen:  :lol:  :idea:  :-D  :evil:  :cry:  8)  :arrow:  :-?  :?:  :!:

引用通告 (0)

› 尚无引用通告。

开灯
如无法留言,请刷尝试新一下页面~~祝您春节愉快!
×