使用外掛實現太容易了,但是我們想讓自己的部落格飛起來就少用外掛吧。
不使用外掛提供通知訪客其評論有回覆的前提條件是伺服器開啟了 mail() 函式,linux 的虛擬主機一般都開啟了的,沒有開啟需要找客服幫忙。如果是 linux VPS 可以自己開啟,方法如下。

一、伺服器已經開啟了 mail() 函式的情況下 (未開啟請看第二大段):
進入 WordPress 後臺 「外觀」—->「編輯」—-> 右邊找到 「functions.php」—-> 在

<?

下一行回車,空出一行後,然後貼上以下程式碼,並儲存即可:

//comment_mail_notify(所有的回覆都會發郵件通知)
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 = 'no-reply@' . preg_replace('#^www.#', '', strtolower($_SERVER['SERVER_NAME']));//發件人 e-mail 地址
    $to = trim(get_comment($parent_id)->comment_author_email);
    $subject = '您在 ['.get_option("blogname").'] 的留言有了回覆';
    $message = '
    <div style="background-color:#eef2fa; border:1px solid #d8e3e8; color:#111; padding:0 15px; -moz-border-radius:5px; -webkit-border-radius:5px; -khtml-border-radius:5px;">
      <p>'.trim(get_comment($parent_id)->comment_author).', 您好!</p>
      <p> 這是您在 《'.get_the_title($comment->comment_post_ID).'》 中的留言:<br />'
       .trim(get_comment($parent_id)->comment_content).'</p>
      <p> 以下是'.trim($comment->comment_author).' 給您的回覆:<br />'
       .trim($comment->comment_content).'<br /></p>
      <p> 您可以<a href="' . htmlspecialchars(get_comment_link($parent_id)) . '"> 點選這裡檢視回復的完整內容.</a></p>
      <p><a href="' . get_option('home') . '">' . get_option('blogname') . '</a> 內容已經更新,歡迎再度光臨!</p>
      <p>(注: 此為系統郵件, 請勿回覆!)</p>
    </div>';
    $from = "From: "" . get_option('blogname') . "" <$wp_email>";
    $headers = "$from
Content-Type: text/html; charset=" . get_option('blog_charset') . "
";
    wp_mail( $to, $subject, $message, $headers );
    //echo 'mail to ', $to, '<br/> ' , $subject, $message; // for testing
  }
}
add_action('comment_post', 'comment_mail_notify');

二、 linux 伺服器開啟 mail() 函式的方法
先是 ssh 連線上 VPS,然後輸入以下命令

vi /usr/local/php/etc/php.ini

在命令模式,使用 VI 的查詢命令 「/」 進行內容查詢:

/mail

如果第一次沒有查詢到,請再次輸入/mail 查詢,直到找到 [mail function]
位置,會看看到以下程式碼:

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =

然後將 sendmail_path =修改為:

sendmail_path = /usr/sbin/sendmail -t -i

然後重啟 php-fpm 程式

/etc/init.d/php-fpm restart

以上步驟完了過後如果發現還不行,那可能是安裝或啟動 sendmail 元件,那麼按以下步驟重新安裝:
安裝元件:

yum install sendmail

重啟程式

/etc/init.d/php-fpm restart

檢查執行情況

/etc/init.d/sendmail status

如果現實 running 則安裝執行成功。
sendmail 啟動停止重啟命令,根據需要選擇後面的 star 、 stop 、 restart

/etc/init.d/sendmail start stop restart