本文旨在记录在设置 typecho 的 CommentToMail 邮件通知插件时遇到的问题以及解决方案。
Q:邮件发送测试成功但实际使用时却无法发信的问题
A: 很可能使用了旧版本的 CommentToMail ,升级到最新版即可解决问题。
这是我最早遇到的问题,在设置了 SMTP 发信,并且发信测试也成功之后,在实际使用注意到时插件并没有正常发信。在检查代码和日志之后发现,我使用的版本的插件里,发信测试会固定使用 mail() 函数进行发送,即使手动更改为 SMTP 发信也是无限报错。因此重新去下载了最新版的插件,问题解决。
淦,下载插件的时候我就不该图省事去第三方插件站...
Q:关于定时任务的一些问题
在设置定时任务的时候,使用了宝塔后台的 "计划任务"-"访问 URL" 功能,运行后发现插件不工作,检查日志后发现报错 :
curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). If the default bundle file isn't adequate, you can specify an alternate file using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option.
这个问题是因为 SSL 证书没有续签引起的,理论上续签 SSL 证书就能解决问题 。
但是由于我更新博客的频率较低,于是决定使用" -k " 参数忽略证书验证。为此改用 "计划任务"-"Shell 脚本" 功能,使用的命令名:
curl -k 直接从插件后台复制的定时任务网址
发现插件依然不执行,再次检查日志。发现虽然网址访问成功,但是返回提示无权限:
{"result":0,"msg":"No permission"}
检查发现问题出在 "&" 符号上, "&" 后面的参数无法获取,导致插件无法验证 key ,解决的方式是在 "&" 前添加 " ",或者是将原本的链接用引号括起来。例:
错误的的格式:
curl - k https://你的域名/action/comment-to-mail?do=deliverMail&key=[你的key]
正确的格式 一:
curl - k https://你的域名/action/comment-to-mail?do=deliverMail\&key=[你的key]
正确的格式 二
curl - k "https://你的域名/action/comment-to-mail?do=deliverMail&key=[你的key]"
PS:CommentToMail 似乎是有不需要定时任务的版本,不过我我个人倾向于需要定时任务的版本,所以没有使用。
虽然在设置的过程中遇到了不少小问题,但是 CommentToMail 确实好用 #笑 。
文章写的很好啊,赞(ㆆᴗㆆ),每日打卡~~