国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

DEDECMS|帝國(guó)CMS|Discuz|PHPCMS|Wordpress|ZBLOG|ECSHOP|蘋果CMS|極致CMS|CMS系統(tǒng)|

服務(wù)器之家 - 建站程序 - Wordpress - WordPress實(shí)現(xiàn)回復(fù)文章評(píng)論后發(fā)送郵件通知的功能

WordPress實(shí)現(xiàn)回復(fù)文章評(píng)論后發(fā)送郵件通知的功能

2019-08-31 15:29WordPress大學(xué) Wordpress

這篇文章主要介紹了WordPress實(shí)現(xiàn)回復(fù)文章評(píng)論后發(fā)送郵件通知的功能,涉及wordpress針對(duì)評(píng)論與郵件的相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了WordPress實(shí)現(xiàn)回復(fù)文章評(píng)論后發(fā)送郵件通知的功能。分享給大家供大家參考,具體如下:

很多時(shí)候,人們都希望在自己的評(píng)論被管理員回復(fù)后會(huì)收到通知。該函數(shù)的作用就是回復(fù)后自動(dòng)郵件通知評(píng)論者。

把下面的代碼加到wordpress的主題函數(shù)里面,然后修改下郵件帳號(hào)密碼。

該函數(shù)是針對(duì)SAE平臺(tái)的wordpress,非SAE平臺(tái)不能使用,有需要的話留言我也會(huì)寫出相應(yīng)方法。
 

復(fù)制代碼

代碼如下:

//郵件回復(fù)
function comment_mail_notify($comment_id) {
define('MAIL_SMTP', 'smtp.exmail.qq.com'); //smtp服務(wù)器
define('MAIL_PORT', 25); //smtp端口
define('MAIL_SENDEMAIL', '123456789@qq.com'); //發(fā)送郵件帳號(hào)
define('MAIL_PASSWORD', '123456'); //發(fā)送郵件密碼
$admin_notify = '1';
$admin_email = get_bloginfo ('admin_email');
$comment = get_comment($comment_id);
$comment_author_email = trim($comment->comment_author_email);
$parent_id = $comment->comment_parent ? $comment->comment_parent : '';
global $wpdb;
if ($wpdb->query("Describe {$wpdb->comments} comment_mail_notify") == '')
$wpdb->query("ALTER TABLE {$wpdb->comments} ADD COLUMN comment_mail_notify TINYINT NOT NULL DEFAULT 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} SET comment_mail_notify='1' WHERE comment_ID='$comment_id'");
$notify = $parent_id ? '1' : '0';
$spam_confirmed = $comment->comment_approved;
if ($parent_id != '' && $spam_confirmed != 'spam' && $notify == '1') {
$wp_email = 'no-reply@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
$to = trim(get_comment($parent_id)->comment_author_email);
$subject = '你在' . get_option("blogname") . '回復(fù)被關(guān)注啦~';
$message = '
<div style="width: 502px; height: auto; margin-bottom: 50px; margin-left: auto; margin-right: auto; font-size: 13px; line-height: 14px;">
<div style="width: 502px; margin-top: 10px;">
<div style="font-size: 16px; color: #373737; text-align: center;">'.get_bloginfo("name").'</div>
<div style="font-size: 15px; color: #f0f7eb; padding: 9px; margin-top: 20px; overflow: hidden; background: #299982; padding-left: 30px; padding-right: 40px;">你在 '. get_the_title($comment-&gt;comment_post_ID) .' 的評(píng)論有了回復(fù):</div>
</div>
<div style="width: 420px; margin-top: 30px; padding: 0 40px 20px; border-left: 1px dashed #299982; border-right: 1px dashed #299982; color: rgba(0,0,0,0.7); background: #f9f9f9; overflow: hidden;">
<div class="one origin" style="border: 1px solid #EEE; overflow: auto; padding: 10px; margin: 1em 0;"><span style="color: #299982;">'. trim(get_comment($parent_id)-&gt;comment_author) .'</span>:'. trim(get_comment($parent_id)-&gt;comment_content) .'</div>
<div class="one reply" style="border: 1px solid #EEE; overflow: auto; padding: 10px; margin: 1em 0 1em 60px;"><span style="color: #299982;">'. trim($comment-&gt;comment_author) .'</span>:'. trim($comment-&gt;comment_content) .'</div>
<p style="margin-bottom: 10px;">點(diǎn)擊<a href="' . htmlspecialchars(get_comment_link($parent_id)) . ' style=">查看完整內(nèi)容</a></p>
<p style="margin-bottom: 10px;">(此郵件由系統(tǒng)發(fā)出,無需回復(fù).)</p>
</div>
</div>
';
$from = "From: \"" . get_option('blogname') . "\" <$wp_email>";
$headers = "$from\nContent-Type: text/html; charset=" . get_option('blog_charset') . "\n";
$mail = new SaeMail(); //對(duì)象
$mail->setOpt(array( 'from' => 'admin@xtwind.com', 'to' => trim($to),//接收信箱
'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');

希望本文所述對(duì)大家基于wordpress的網(wǎng)站建設(shè)有所幫助。

 

 

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 欧洲一级视频 | 免费视频一区二区 | 日韩精品一区二区三区 | 亚洲的天堂 | 国产一区网站 | 国内精品在线视频 | 国产日皮视频 | 欧美在线免费观看 | 国产成人高清视频 | 欧美一级免费看 | 国产精品视频久久 | 久久综合伊人 | 国产精品99精品久久免费 | 一级毛片观看 | 一区不卡 | 每日更新av | 亚洲激情一区二区三区 | 免费观看a级毛片在线播放 成人片免费看 | 永久黄网站色视频免费观看w | 久久精品日产第一区二区三区 | 亚洲成a人| 99精品欧美一区二区三区综合在线 | 国产精品久久久久久久久久新婚 | 中文字幕精品一区久久久久 | 国产成人99久久亚洲综合精品 | 精品久久久久久亚洲综合网 | 欧美精品国产精品 | 日韩一级精品视频在线观看 | 日韩一区二区三区在线观看 | 精品一区二区视频 | 久久久久久免费 | 国产精品一区二区视频 | 亚洲成人精品一区 | 国产欧美日韩 | 国产精品久久久久无码av | 成人乱码一区二区三区av | 欧洲一区二区三区精品 | 亚洲一区二区在线看 | 毛片网| 黑人巨大精品欧美黑白配亚洲 | 午夜精品一区二区三区在线视频 |