Wordpress 在VPS /Hosting 中常常預到server沒有PHPMAL,所以就要使用SMTP來send信。
簡單隨便安裝一個插件即可,但如果預上網站
和電郵
服務在兩台不同的server上,你可以設定了SMTP都會出錯
下面我以這個插件Easy WP SMTP
做例子,其實主要也是修改PHPMailer的代碼
以下修改針對版本為Easy WP SMTP 2.1.0
easy-wp-smtp/src/Processor.php
改1處
找到以下
$phpmailer->Host = $connection_options->get( $mailer, 'host' );
$phpmailer->Port = $connection_options->get( $mailer, 'port' );
加入一行,變成如下
$phpmailer->Host = $connection_options->get( $mailer, 'host' );
$phpmailer->Port = $connection_options->get( $mailer, 'port' );
$phpmailer->Hostname = $connection_options->get( $mailer, 'host' );
easy-wp-smtp/inc/deprecated/class-easywpsmtp.php
改2處
找到以下
$phpmailer->Host = $this->opts['smtp_settings']['host'];
$phpmailer->Port = $this->opts['smtp_settings']['port'];
加入一行,變成如下
$phpmailer->Host = $this->opts['smtp_settings']['host'];
$phpmailer->Port = $this->opts['smtp_settings']['port'];
$phpmailer->Hostname = $this->opts['smtp_settings']['host'];
找到以下
$mail->Host = $this->opts['smtp_settings']['host'];
$mail->Port = $this->opts['smtp_settings']['port'];
加入一行,變成如下
$mail->Host = $this->opts['smtp_settings']['host'];
$mail->Port = $this->opts['smtp_settings']['port'];
$mail->Hostname = $this->opts['smtp_settings']['host'];
修改後請記得不要更新此插件