首先配置smtp請參考此文,如果不能成功,再看下文 WordPress無法發送郵件的解決方法
對應普通虛擬主機來說,要開啟 fsockopen(一般是在主機商提供的管理後台中可以開啟,不會的請聯系主機商客服) 。
在網站的 /wp-Includes/ 目錄下找到並打開 class-smtp.php 大概是 274-282 行的位置(不同版本WordPress可能行數不同),找到如下代碼: $this->smtp_conn = @stream_socket_client(
$host . ":" . $port,
$errno,
$errstr,
$timeout,
STREAM_CLIENT_CONNECT,
$socket_context
);
將此代碼注釋掉或者刪除,然後修改為以下代碼:
$this->smtp_conn = fsockopen($host, $port, $errno, $errstr);
修改後,如果還是無法發送郵件,在上面步驟完成的情況下繼續添加如下代碼:
/**
* 修複 WordPress 郵件發送”
* 以QQ郵箱為例**/
function mail_smtp( $phpmailer ){
$phpmailer->From = "service@0513c.com"; //發件人
$phpmailer->FromName = "技術宅"; //發件人昵稱
$phpmailer->Host = "smtp.qq.com"; //SMTP服務器地址
$phpmailer->Port = 25; //SMTP端口,常用的有25、465、587,具體穀歌百度
$phpmailer->SMTPSecure = ""; //SMTP加密方式,常用的有SSL/TLS,具體穀歌百度
$phpmailer->Username = "wpyou@qq.com"; //郵箱帳號
$phpmailer->Password = *********; //郵箱密碼
$phpmailer->IsSMTP(); //使用SMTP發送
$phpmailer->SMTPAuth = true; //啟用SMTPAuth服務
}
add_action('phpmailer_init','mail_smtp');
執行以上操作後您網站的郵件收發功能應該就可以實現了。如果還是沒法解決,這可能就是只修改代碼無法解決了,請聯系主機商解決處理吧。
更多文章:http://liuyanzhao.com/662.html
本文地址:http://liuyanzhao.com/3269.html
轉載請注明