前几天帮人折腾了这个功能,很早以前弄过,后来忘记了。
第一步:开端口
服务器开25端口,一般IDC商后台可手动申请开通。
第二步:安装Easy WP Smtp插件。
WP插件平台有,直接去下载安装即可。全英文的,设置如下,设置完之后记得在选框第三个中测试一下是否可以发信:
第三步:上代码
在主题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 = 'admin@163.com' . preg_replace('#^www.#', '', strtolower($_SERVER['SERVER_NAME'])); //改为你的邮箱
$to = trim(get_comment($parent_id)->comment_author_email);
$subject = '[' . get_option("blogname") . '] 您的留言有了新回复';
$message = '
<div style="width: 60%;margin: 0 auto">
<div style="font-size: 28px;line-height: 28px;text-align: center;"><p>' . trim(get_comment($parent_id)->comment_author) . ', 您好!</p></div>
<div style="border-bottom: 1px solid #eee;padding-top: 10px;">
<p style="color: #999;">您曾在《' . get_the_title($comment->comment_post_ID) . '》的留言:</p>
<p style="font-size: 18px;">' . trim(get_comment($parent_id)->comment_content) . '</p>
</div>
<div style="border-bottom: 1px solid #eee;padding-top: 10px;">
<p style="color: #999;">' . trim($comment->comment_author) . ' 给您的回复:</p>
<p style="font-size: 18px;">' . trim($comment->comment_content) . '</p>
<p style="text-align: center;font-size: 12px;padding-bottom: 20px;"><a style="border: 1px solid #3297fb;color: #3297fb;padding: 7px 14px;text-decoration: none;-moz-border-radius: 4px;-webkit-border-radius: 4px;border-radius:4px;" href="' . esc_attr(get_comment_link($parent_id, array('type' => 'comment'))) . '">点击查看</a></p>
</div> <div style="font-size: 12px;color: #999;text-align: center;">
<p>此邮件由系统自动发送,请勿回复</p>
<p>© <a href="http://www.newpm.net" style="color: #999;text-decoration: none;">' . get_option('blogname') . '</a></p>
</div>
</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 ); } }
add_action('comment_post', 'comment_mail_notify');
温馨提示:做备份是一个良好的习惯
微信扫描二维码阅读
龙哥 发表于 1年前 (2021-09-06),共1967字
版权声明:①欢迎转载但请注明出处。②如涉及版权联系(izhailong#qq.com)删除!
转载请注明:记录一次wordpress回复留言邮件通知 || https://www.izhailong.com/495.html
本文由:版权声明:①欢迎转载但请注明出处。②如涉及版权联系(izhailong#qq.com)删除!
转载请注明:记录一次wordpress回复留言邮件通知 || https://www.izhailong.com/495.html
暂无评论