前言
之前一直使用的LoveKKComment
插件失效了,所以就物色新的邮件提醒插件
契机
好早之前就看到过熊猫小A修改制作的mailer评论邮件提醒插件,无奈我所使用的正式版版不支持(建站时想着网站稳定即可,就不追求新功能了),就搁置了(又不是不能用)。
最近,LoveKKComment
插件失效了,emmmmm~机会来了,换了吧,在加之纸盒博客博主的邮件模板真的吸引到我了,就换吧。
流程:升级Typecho-安装插件配置-美化
效果如图:


升级Typecho
- 下载最新版(开发版)Typecho源程序:http://typecho.org/download
删除原博客文件夹中的
- admin
- var
- index.php
将下载的压缩包中下列文件上传至原博客目录即可
- admin
- var
- index.php
- 再次进入后台会提示升级程序,点击完成即可完成升级
安装配置mailer
- 下载插件(需要使用 Typecho 开发版(17.11.15 及以上版本))
- 上传至插件目录,后台启用后设置相关信息
- 打开
handsome/component/comments.php
在适当的位置添加代码(开启选择是否接受邮件回复)
- (参考:我放在190行左右的提交按钮代码下面,效果参见本文评论区)
#自用
<span>
<label class="i-switch i-switch-sm bg-dark m-b-ss m-r">
<input name="receiveMail" type="checkbox" value="yes" checked />
<i></i>
</label>
<label for="receiveMail"><strong>接收</strong>邮件通知</label>
</span>
#原版
<span>
<input name="receiveMail" type="checkbox" value="yes" checked />
<label for="receiveMail"><strong>接收</strong>邮件通知</label>
</span>
- handsome6.0注意修改代码
发现handsome/component/comments.php
173行:<input type="hidden" name="receiveMail" id="receiveMail" value="yes" />
需要给其加上注释,如:
# handsome/component/comments.php 173行
<!-- <input type="hidden" name="receiveMail" id="receiveMail" value="yes" /> -->
- 在博客评论区 form 元素中合适位置添加
<span>
<input name="receiveMail" type="checkbox" value="yes" checked />
<label for="receiveMail"><strong>接收</strong>邮件通知</label>
</span>
- 如果没有或者找不到相关评论区代码
#打开插件中的Plugin.php文件,在272行找到
$r = 0;
// 当前评论是否接受回复提醒
if (isset($_POST['receiveMail']) && 'yes' == $_POST['receiveMail']) {
$r = 1;
}
修改为:
$r = 1;
// 当前评论是否接受回复提醒
//if (isset($_POST['receiveMail']) && 'yes' == $_POST['receiveMail']) {
// $r = 1;
//}
美化
在此感谢纸盒博客修改的样式
<div style="width: 550px;height: auto;border-radius: 5px;margin:0 auto;box-shadow: 0px 0px 20px #888888;position: relative;">
<div style="background-image: url(https://cdn.zggsong.cn/2020/03/21/f913433848e78.png);width:550px;height: 250px;background-size: cover;background-repeat: no-repeat;border-radius: 5px 5px 0px 0px;"></div>
<div style="background-color:white;line-height:180%;padding:0 15px 12px;width:520px;margin:10px auto;color:#555555;font-family:'Century Gothic','Trebuchet MS','Hiragino Sans GB',微软雅黑,'Microsoft Yahei',Tahoma,Helvetica,Arial,'SimSun',sans-serif;font-size:12px;margin-bottom: 0px;">
<h2 style="font-size:14px;font-weight:normal;padding:13px 0 10px 8px;"><span style="color: #ff7272;font-weight: bold;"></span>您的<a style="text-decoration:none;color: #ff7272;" href="{{post_permalink}}" target="_blank">《{{post_title}}》</a>有了新的回复:</h2>
<div style="padding:0 12px 0 12px;margin-top:18px">
<p><strong>{{comment_author_name}}</strong> 给您的评论:</p>
<style type="text/css">
.comment>img{margin: 0px 6px 5px 6px;width: 25px;}
</style>
<p class="comment" style="background-color: #f5f5f5;border: 0px solid #DDD;border-radius: 5px;padding: 10px 15px;margin:18px 0">{{comment_content}}</p>
<p>详细信息:</p>
<p style="background-color: #f5f5f5;border: 0px solid #DDD;border-radius: 5px;padding: 10px 15px;margin:18px 0">IP:{{ip}}<br />邮箱:<a style="text-decoration:none;color: #ff7272;" href="mailto:{{comment_author_mail}}">{{comment_author_mail}}</a><br />状态:{{status}} [<a style="text-decoration:none;color: #ff7272;" href='{{manage_url}}' target='_blank'>管理评论</a>]</p>
</div>
</div>
<a style="text-decoration: none;color: rgb(255, 255, 255);width: 40%;text-align: center;background-color: rgb(255, 114, 114);height: 40px;line-height: 40px;box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.3);display: block;margin: auto;" href="{{comment_permalink}}" target="_blank">查看回复的完整內容</a>
<div style="color:#8c8c8c;;font-family: 'Century Gothic','Trebuchet MS','Hiragino Sans GB',微软雅黑,'Microsoft Yahei',Tahoma,Helvetica,Arial,'SimSun',sans-serif;font-size: 10px;width: 100%;text-align: center; padding-bottom: 1px;">
<p>©2019-2020 Copyright {{site_name}}</p>
</div>
</div>
<div style="width: 550px;height: auto;border-radius: 5px;margin:0 auto;box-shadow: 0px 0px 20px #888888;position: relative;padding-bottom: 5px;">
<div style="background-image: url(https://cdn.zggsong.cn/2020/03/21/f913433848e78.png);width:550px;height: 300px;background-size: cover;background-repeat: no-repeat;border-radius: 5px 5px 0px 0px;"></div>
<div style="width: 200px;height: 40px;background-color: rgb(255, 114, 114);margin-top: -20px;margin-left: 20px;box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.3);color: rgb(255, 255, 255);text-align: center;line-height: 40px;">Dear: {{comment_parent_author_name}}</div>
<div style="background-color:white;line-height:180%;padding:0 15px 12px;width:520px;margin:30px auto;color:#555555;font-family:'Century Gothic','Trebuchet MS','Hiragino Sans GB',微软雅黑,'Microsoft Yahei',Tahoma,Helvetica,Arial,'SimSun',sans-serif;font-size:12px;margin-bottom: 0px;">
<h2 style="font-size:14px;font-weight:normal;padding:13px 0 10px 8px;"><span style="color: #12ADDB;font-weight: bold;"></span>您在<a style="text-decoration:none;color: #ff7272;" href="{{post_permalink}}" target="_blank">《{{post_title}}》</a>的评论有了新的回复:</h2>
<div style="padding:0 12px 0 12px;margin-top:18px">
<style type="text/css">
.comment>img{margin: 0px 6px 5px 6px;width: 25px;}
</style>
<p>您的评论:</p>
<p class="comment" style="background-color: #f5f5f5;border: 0px solid #DDD;border-radius: 5px;padding: 10px 15px;margin:18px 0">{{comment_parent_content}}</p>
<p><strong>{{comment_author_name}}</strong> 给您的回复:</p>
<p class="comment" style="background-color: #f5f5f5;border: 0px solid #DDD;border-radius: 5px;padding: 10px 15px;margin:18px 0">{{comment_content}}</p>
</div>
</div>
<div style="color:#8c8c8c;;font-family: 'Century Gothic','Trebuchet MS','Hiragino Sans GB',微软雅黑,'Microsoft Yahei',Tahoma,Helvetica,Arial,'SimSun',sans-serif;font-size: 10px;width: 100%;text-align: center;word-wrap:break-word;margin-top: -30px;">
<p style="padding:20px;">萤火虫消失之后,那光的轨迹仍久久地印在我的脑际。那微弱浅淡的光点,仿佛迷失方向的魂灵,在漆黑厚重的夜幕中彷徨。——《挪威的森林》村上春树</p>
</div>
<a style="text-decoration:none; color:#FFF;width: 40%;text-align: center;background-color:#ff7272;height: 40px;line-height: 35px;box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.30);margin: -10px auto;display: block;" href="{{comment_permalink}}" target="_blank">查看回复的完整內容</a>
<div style="color:#8c8c8c;;font-family: 'Century Gothic','Trebuchet MS','Hiragino Sans GB',微软雅黑,'Microsoft Yahei',Tahoma,Helvetica,Arial,'SimSun',sans-serif;font-size: 10px;width: 100%;text-align: center;margin-top: 30px;">
<p>本邮件为系统自动发送,请勿直接回复~</p>
</div>
<div style="color:#8c8c8c;;font-family: 'Century Gothic','Trebuchet MS','Hiragino Sans GB',微软雅黑,'Microsoft Yahei',Tahoma,Helvetica,Arial,'SimSun',sans-serif;font-size: 10px;width: 100%;text-align: center;padding-bottom: 1px;">
<p>©2019-2020 Copyright {{site_name}}</p>
</div>
</div>
结语
版权属于:SWJ(除特别注明外)
本文链接:https://blog.zggsong.cn/archives/1082.html
本站文章采用CC BY-NC-SA 4.0进行许可,请在转载时注明出处及本声明!
配置里的邮件服务器是填自己的邮箱吗!我的怎么不行呜呜呜
博主,我的配置没问题,没报任何错误,按照你的操作,添加了代码,但评论了,却没有发邮件,什么问题,求解
补充一下,根目录下的install.php也要替换,不然后台打不开,不要问我为什么,我重装了
LoveKKComment还能用呀哈哈哈哈,我的博客还在用⌇●﹏●⌇
嗯嗯,可能是我的smtp密码需要重新获取一下,不过原版的邮件通知的逻辑:博主回复博主邮件通知就很烦
请问一下大佬!
为什么插件都配置好了保存设置,提示:向邮件服务器发送指令失败?
端口选择587+tls加密方式试试
谢谢!|´・ω・)ノ
需要修改模板的,一律不用,除非找人帮我改。太难了(/ω\)
稍微折腾一下只为了自己用的更舒服嘛