我的博客采用的是CommentToMail插件用来发送评论邮件通知的,自从使用了微信评论通知之后,这个插件好像就失效了,我并不知道是不是因为这个插件的原因导致的这个问题,但是确实是好几天都发送失败,后来通过折腾发现并不是微信通知的原因,最后通过更换邮件系统解决问题。

发现的问题

自从本月26号开始,邮件提醒就已经失效了,而我居然昨天才发现,这几天的评论只有微信通知,况且我也没有打开邮件回复通知自己。

解决过程

最开始我以为是微信插件的原因,我就先把他给禁用掉了,然后测试发现还是无法使用,提示smtp各种错误,上网找了很多的解决办法,最后通过更换邮箱系统解决了这个问题。

报错的信息

  • The following From address failed: master@kaygb.top : MAIL FROM command failed,”MAIL FROM” is non-local account
    ,501,SMTP server error: MAIL FROM command failed Detail: “MAIL FROM” is non-local account
    SMTP code: 501SMTP server error: MAIL FROM command failed Detail: “MAIL FROM” is non-local account
    SMTP code: 501
  • Mailer Error: SMTP Error: data not accepted.
  • SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

关于第二条,其实是因为smtp密码输入错位的问题。

更换smtp邮箱

于是我换掉了我的企业邮箱,注册了一个网易yeah邮箱并打开了smtp服务

然后我在网上找到了一个修改版的插件,尝试之后是可以发送邮件的,但是只能收到评论通知,却并没有发送回复邮件通知。这是我以为是插件的问题,然后我又换回之前的插件,发现还是有点毛病,这个时候我就觉得是邮件系统的问题了。

更换阿里邮件推送服务

最终,我使用了阿里的邮件推送服务解决了这个问题

阿里云邮件推送服务每天有200封免费的邮件,足够我的小站使用的了

开通邮件服务

打开邮件推送控制台https://dm.console.aliyun.com

配置发信域名

在发信域名这里选择新建域名,输入未被解析过的二级域名

新建域名.png

点击配置

域名配置.png

然后根据要求在DNS解析控制台进行四条解析

域名配置1.png

域名解析.png

域名解析1.png

解析完成之后在发信域名点击验证左边显示验证通过即为成功

发信域名验证.png

配置发信地址

这个发信地址也就是用来SMTP发信的邮箱账号,所以可以按照自己的喜好设置。

侧边选择发信地址,然后点击新建发信地址

新建发信地址.png

发信地址配置.png

关于发信类型,我填的是触发邮件,有人说触发邮件不太稳定,也可以选择批量邮件,这个大家自行斟酌

然后需要到填入的回信地址邮箱验证一下

回信地址验证.png

点击验证会跳转到浏览器,登录阿里云账号即可验证成功。

然后配置一下SMTP的密码

smtp密码.png

到这里邮箱就差不多设置完成了。接下来是站点的配置

插件配置

插件配置.png

  • 发信方式选择smtp

  • smtp地址和企业邮箱不同,为:smtpdm.aliyun.com

  • 端口选择ssl加密端口465

  • SMTP用户是刚才设设置的发信地址

  • 密码为设置的SMTP密码

  • 勾选服务器需要验证和ssl加密(一般25端口都是被封掉的,所以我推荐465端口)

到这里差不多配置完成了,可以测试一下是否可以成功发送

邮件发送测试.png

美化评论者邮件模板

评论者的视觉体验是很重要的,于是我只修改了guest.html的内容,代码是借鉴了网上的内容进行的修改,不过我忘记是在哪里找到的了,如果原作者看到可以在评论区给我留言,我会注明原作者。

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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<base target="_blank" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://kaygb.top/static/style.css">
<meta charset="utf-8">
<style id="cloudAttachStyle" type="text/css">
#divNeteaseBigAttach, #divNeteaseBigAttach_bak{display:none;}
</style>
<style>
::-webkit-scrollbar{ display: none; }
.container{
max-width:500px;margin:20px auto;background-color:#eee;box-shadow:2px 2px 5px #888888;font-family:-apple-system,BlinkMacSystemFont,&quot;
}
.mail-box{
width: 100%;
}
.mail-header{
background:url('###这里是头图的地址,请修改###') center center no-repeat;background-size:100% auto;width:100%;height:220px;box-sizing:border-box;overflow-y:hidden;
}
.mail-sitetitle{
width:100%;background:#bd57a7;color:#ffffff;height: 66px;
}
.mail-sitetitle p{
font-size:15px;word-break:break-all;padding: 23px 32px;margin:0;
}
.mail-sitetitle p a{
text-decoration:none;color: #ffffff;
}
.mail-p3{
border-radius:3px;margin:0;margin-bottom:10px;padding:15px 10px;
}
.mail-p3 strong{
display:inline-block;line-height:20px;background-color:#ec6149;color:#fff;border-radius:4px;padding:5px 10px;height:20px;
}
</style>
<div class="container">
<div class="mail-box">
<div class="mail-header">
</div>
<div class="mail-sitetitle">
<p >您在<a href="https://kaygb.top/"> {siteTitle} </a>上的评论有回复啦!</p>
</div>
<p class="mail-p3">
<strong>{author_p}</strong>&nbsp;您在&nbsp;<strong><a href="{permalink}" style="text-decoration:underline;color:inherit;">{title}</a></strong>&nbsp;的评论:
</p>
<div style="margin:40px auto;width:95%">

<p style="background: #fafafa repeating-linear-gradient(-45deg,#fff,#fff 1.125rem,transparent 1.125rem,transparent 2.25rem);box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);margin:20px 0px;padding:15px;border-radius:5px;font-size:14px;color:#555555;">{text_p}</p>

<p class="mail-p3" style="border-radius:3px;margin:0;margin-bottom:10px;padding:15px 10px;">
<strong style="display:inline-block;line-height:20px;background-color:#00a7e0;color:#fff;border-radius:4px;padding:5px 10px;height:20px;">{author}</strong>&nbsp;&nbsp;<strong><a href="{permalink}" style="text-decoration:underline;color:inherit;">{title}</a></strong>&nbsp;回复你:
</p>
<p style="background: #fafafa repeating-linear-gradient(-45deg,#fff,#fff 1.125rem,transparent 1.125rem,transparent 2.25rem);box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);margin:20px 0px;padding:15px;border-radius:5px;font-size:14px;color:#555555;">{text}</p>

<p class="footer" style="border-top: 1px solid #DDDDDD; padding-top: 6px; margin-top: 15px; color: #838383; text-align: center;">你可以点击此链接
<a target="_blank" href="{permalink}">查看完整內容</a> | 欢迎再次来访
<a href="https://kaygb.top/">KAYGB</a>
</p>
<p class="footer" style="padding-top: 6px; margin-top: 15px; color: #838383; text-align: center;">
本邮件为自动发送,请勿直接回复,您可以<a href="https://kaygb.top/msg.html">给我留言</a>
</p>
</div>
<p class="mail-footer" style="border-radius:3px;margin:0;padding:15px 20px;text-align:right;">
{siteTitle} 献上诚挚的问候
</p>
<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;">
<p>©2018-<script>
var myDate = new Date();

document.write(myDate.getFullYear());
</script> Copyright <a href="https://kaygb.top/">KAYGB</a></p>
</div>
</div>
</div>
<style type="text/css">
body{font-size:14px;font-family:arial,verdana,sans-serif;line-height:1.666;padding:0;margin:0;overflow:auto;white-space:normal;word-wrap:break-word;min-height:100px}
td, input, button, select, body{font-family:Helvetica, 'Microsoft Yahei', verdana}
pre {white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word;width:95%}
th,td{font-family:arial,verdana,sans-serif;line-height:1.666}
img{ border:0}
header,footer,section,aside,article,nav,hgroup,figure,figcaption{display:block}
blockquote{margin-right:0px}
</style>
<style id="ntes_link_color" type="text/css">a,td a{color:#064977}</style>

将上述代码替换只插件的编辑邮件模板的guest文件中,内容里面的头图还有域名地址请注意修改为自己的的域名

编辑邮件模板.png

美化后的界面预览

邮件模板预览.png

部分邮箱系统可能无法正常显示样式。

最后

到这里我的邮箱评论通知就配置好了,然后我也打开了评论微信通知,可以一起使用,很方便。如果您遇到什么问题或是有什么疑问都可以在下方留言。

评论