WordPress实现回复文章评论后发送邮件通知的功能

WordPress实现回复文章评论后发送邮件通知的功能,第1张

WordPress实现回复文章评论后发送邮件通知的功能

详细介绍了wordpress对文章内容回复完评论后发送邮件通知的功能,涉及到WordPress对评论和邮件的实际 *** 作方法,一定要朋友们参考。

本文描述了WordPress在回复文章评论后发送邮件通知的作用。分享给大家参考。实际上是这样的:

在许多情况下,人们希望当他们的意见得到经理的回应时会得到通知。该功能是在回复后自动通过电子邮件通知评论者。

将以下代码添加到wordpress的主题样式函数中,然后更改邮箱登录密码。

此功能用于SAE服务平台的wordpress。它不能应用于非SAE服务平台。如果有必要,可以在留言板上留言,因为我会以相对的方式来写。

复制代码编码如下://mailreply
函数comment_mail_notify($comment_id){
define('mail_SMTP','SMTP.exmail.QQ.com');//SMTPwebserver
define('MAIL_PORT',25);//smtp端口
define('mail_sendemail','123456789@QQ.com');//发送邮件账号
定义('mail_password','123456');//发送邮件登录密码
$admin_notify='1';
$admin_email=get_bloginfo('admin_email');
$comment=get_comment($comment_id);
$comment_author_email=trim($comment->;评论_作者_邮箱);
$parent_id=$comment->;评论_家长?$comment->;comment_parent:“”;
global$wpdb;
if($wpdb->;查询("Describe{$wpdb->;comments}comment_mail_notify")=='')
$wpdb->;query("ALTERTABLE{$wpdb->;comments}ADD列comment_mail_notifyTINYINTNOTNULL默认为0;");
if(($comment_author_email!=$admin_email&&isset($_POST['comment_mail_notify'])||($comment_author_email==$admin_email&;&$admin_notify=='1')
$wpdb->;query("UPDATE{$wpdb->;comments}SETcomment_mail_notify='1'其中comment_ID='$comment_ID'";
$notify=$parent_id?'1':'0';
$spam_confirmed=$comment->;评论_已批准;
if($parent_id!=“”&;&$spam_已确认!='垃圾邮件'&&$notify=='1'){
$wp_email='无答复@'。preg_replace('#^www\.#','',strtolow($_SERVER['SERVER_NAME']);
$to=trim(get_comment($parent_id)->;评论_作者_邮箱);
$subject='你去过'。get_option("blogname")。回复被关心~';
$message='
<;divstyle="width:502px;高度:自动;边距-底部:50px左边距:自动;右边距:自动;字体大小:13px行高:14px">
<;divstyle="width:502px;上边距:10px">
<;divstyle="font-size:16px;颜色:#373737;文本对齐:居中;">。get_bloginfo("name"),'</div>;
<;divstyle="font-size:15px;颜色:#f0f7EB;填充:9px边距-顶部:20px溢出:隐藏;背景:#299982;左填充:30px右填充:40px">你已经进去了。get_the_title($comment->;'Comment_post_ID)。'的评论有回复:<;/div>;
<;divstyle="width:421080x;边距-顶部:30px填充:040px20pxborder-left:1px虚线#299982;border-right:1px虚线#299982;颜色:rgba(0,0,0,0.7);背景:#f9f9f9溢出:隐藏;">
<;divclass="oneorigin"style="border:1pxsolid#EEE;溢出:自动;填充:10px边距:1em0;"><spanstyle="color:#299982;">。trim(get_comment($parent_id)-&;gt;'评论_作者)。'</span>。:'.trim(get_comment($parent_id)-&;gt;comment_content)。”</div>;
<;divclass="onereply"style="border:1pxsolid#EEE;溢出:自动;填充:10px边距:1em01em60px"><spanstyle="color:#299982;">。trim($comment-&;gt;'评论_作者)。'</span>。:'.trim($comment-&;gt;comment_content)。”</div>;
<;pstyle="margin-bottom:10px;">单击'SMTP_host'=>;MAIL_SMTP,//host
'SMTP_port'=>;MAIL_PORT,//PORT
'SMTP_username'=>;MAIL_SENDEMAIL,
'SMTP_password'=>;MAIL_PASSWORD,
'subject'=>;$subject,
'content'=>;$message,
'content_type'=>;HTML'
//'TLS'=>;true,
//'charset'=>;gbk’));
$ret=$mail->;send();
}
}
add_action('comment_post','comment_mail_notify');

如果上面的应用不好,可以看看之前的文章:

php使用SAE原生邮件类发送各类邮件的方法

期待以上对基于wordpress的企业网站建设有所帮助。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/773965.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-03
下一篇 2022-05-03

发表评论

登录后才能评论

评论列表(0条)

保存