#wordpress #smtp #邮箱这个功能,因为到处访问肉身拉流量,还是挺需要的。主要是别人评论你自己博客的文章,wordpress默认是没有邮件提醒你的。挺神奇的。我之前装过一个评论提醒,发现那个是评论回复提醒,意思是你的评论(而不是文章被回复)的提醒。我装了几个没有效果仔细阅读中英文发现的,确实同一个插件有中文英文2种。 英文名字是 Comment Reply Email 功能相同,就是设置上好像英文的好点。这个不是今天重点。重点在后面哈。
博客精简计划:取消评论 - 印记这个文章确实写出了评论不回复的缺点,作者关闭了也是一种办法,更加专心的做更重要的事,无可厚非。对我来说还是有点启发的。让我想起有的人在他那儿评论都是秒回,还不是AI回复的,我是这么认为的。比如obaby@mars – Artificial Intelligence / Reverse Engineering / Internet of Things / Full Stack Developer阿和憩站 - 记录生活点滴,刻画人生轨迹都是大美女。
这个拉流量 向老张博客 | 生活琐记,技术折腾,乐在记录点滴与分享!学习的,某次问老张他那访问量怎么那么高。他说都是他一个一个拉过来的,颇为实在,想想自己,没有啥长处,应该多努力,多学习点笨办法并且贯彻执行下去。更别说像obaby@mars – Artificial Intelligence / Reverse Engineering / Internet of Things / Full Stack Developer这样女 才 女 貌 冰雪聪明人气顶高的女程序员,还到处访问。我去留言的时候大概率已经看到有了她的留言了。还有不少博主也是十分勤奋的,不一一列举了。
反面也有的,有的人为了让你去他公众号,或者他的博客没设置提醒,留言一次石沉大海,两次杳无音信,三次音信全无,四次还有啥好说的了。走为上策。也有你不想留言只想看看就行的,比如和菜头的独立博客。其实很多组装出来(先抑后扬,只有技术好爱折腾的牛人才能玩得了)的静态博客都可以用不少第三方(程序员自己code的)的评论系统,也是有评论系统的,比如留言板 | 2BROEAR - 2B博客留言板valine 可以画画 他用的wordpress本来自带不用,本来 valine自带数据库,可能怕丢失,又转到自己的服务器上。 调试了花了不少时间文章都有十多篇了。可以画画的评论区下图
就是遇到需要github等第三方账号登陆的比较麻烦。
然后所说发邮件的事情smtp使用前 开启smtp服务 不知道什么时候开始必须手机短信验证了。多年之前验证spark飞机邮箱时候用过。没这个手机验证可能。
wordpress 安装 WP Mail SMTP
SMTP HOST -> 可以到邮箱的客户端设置中找到(例如QQ邮箱:smtp.qq.com)
Encryption -> 选择加密协议SSL
SMTP端口 -> 同上,一般ssl端口号为465;普通端口25
SMTP认证 -> YES
SMTP UserName -> 邮箱地址
SMTP Password -> 一般为生成的专门为客户端登录的密码 就是刚才短信验证通过后出现的授权码
发件人地址 -> 你用来发送邮件的邮箱地址
发件人昵称 -> 用于显示发件人————————————————
下面这个代码如果主题有的话 就不用使用了。我感觉收到wordpress的那个安装成功的邮件就是成功了,后面刚好有人评论我第一时间就在微信上收到了提示。赶紧去回复了。
如果测试几次没有效果必须添加代码 就是 在 function.php 中添加一下代码
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'])); $to = trim(get_comment($parent_id)->comment_author_email); $subject = '[通知]您的留言有了新的回复'; $message = ' <div"background:#ececec;width: 100%;padding: 50px 0;text-align:center;"> <div"background:#fff;width:750px;text-align:left;position:relative;margin:0 auto;font-size:14px;line-height:1.5;"> <div"zoom:1;padding:25px 40px;background:#518bcb; border-bottom:1px solid #467ec3;"> <h1"color:#fff; font-size:25px;line-height:30px; margin:0;"><a"' . get_option('home') . '""text-decoration: none;color: #FFF;">' . htmlspecialchars_decode(get_option('blogname'), ENT_QUOTES) . '</a></h1> </div> <div"padding:35px 40px 30px;"> <h2"font-size:18px;margin:5px 0;">Hi ' . trim(get_comment($parent_id)->comment_author) . ':</h2> <p"color:#313131;line-height:20px;font-size:15px;margin:20px 0;">您有一条留言有了新的回复,摘要信息请见下表。</p> <table"0""font-size:14px;text-align:center;border:1px solid #ccc;table-layout:fixed;width:500px;"> <thead> <tr> <th"padding:5px 0;text-indent:8px;border:1px solid #eee;border-width:0 1px 1px 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:normal;color:#a0a0a0;background:#eee;border-color:#dfdfdf;""235px;">原文</th> <th"padding:5px 0;text-indent:8px;border:1px solid #eee;border-width:0 1px 1px 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:normal;color:#a0a0a0;background:#eee;border-color:#dfdfdf;""235px;">回复</th> <th"padding:5px 0;text-indent:8px;border:1px solid #eee;border-width:0 1px 1px 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:normal;color:#a0a0a0;background:#eee;border-color:#dfdfdf;""100px;">作者</th> <th"padding:5px 0;text-indent:8px;border:1px solid #eee;border-width:0 1px 1px 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:normal;color:#a0a0a0;background:#eee;border-color:#dfdfdf;""90px;" >操作</th> </tr> </thead> <tbody> <tr> <td"padding:5px 0;text-indent:8px;border:1px solid #eee;border-width:0 1px 1px 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">' . trim(get_comment($parent_id)->comment_content) . '</td> <td"padding:5px 0;text-indent:8px;border:1px solid #eee;border-width:0 1px 1px 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">'. trim($comment->comment_content) . '</td> <td"padding:5px 0;text-indent:8px;border:1px solid #eee;border-width:0 1px 1px 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">' . trim($comment->comment_author) . '</td> <td"padding:5px 0;text-indent:8px;border:1px solid #eee;border-width:0 1px 1px 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"><a"'.get_comment_link( $comment->comment_ID ).'""color:#1E5494;text-decoration:none;vertical-align:middle;""_blank">查看回复</a></td> </tr> </tbody> </table> <br> <div"font-size:13px;color:#a0a0a0;padding-top:10px">该邮件由系统自动发出,如果不是您本人操作,请忽略此邮件。</div> <div"qmSysSign""padding-top:20px;font-size:12px;color:#a0a0a0;"> <p"color:#a0a0a0;line-height:18px;font-size:12px;margin:5px 0;">' . htmlspecialchars_decode(get_option('blogname'), ENT_QUOTES) . '</p> <p"color:#a0a0a0;line-height:18px;font-size:12px;margin:5px 0;"><span"border-bottom:1px dashed #ccc;""5""">' . date("Y年m月d日",time()) . '</span></p> </div> </div> </div> </div>'; $from = "From: \"" . htmlspecialchars_decode(get_option('blogname'), ENT_QUOTES) . "\" <$wp_email>"; $headers = "$from\nContent-Type: text/html;" . get_option('blog_charset') . "\n"; wp_mail( $to, $subject, $message); }}add_action('comment_post', 'comment_mail_notify');#wordpress #wp评论