把項目環境升級到PHP7.1后,發現在不使用SSL時可以使用IP發郵件,可設置成SSL時就只能使用hostname發送,PHP提示的錯誤信息大致意思是說,IP與hostname無法通過SSL驗證,修改ci框架中Email類第2061行,結果又可以正常發郵件了,故作此記錄。
// 修改的代碼 $ctx = stream_context_create(array( 'ssl' => array( 'verify_peer_name' => FALSE, ) )); $this->_smtp_connect = stream_socket_client( $ssl . $this->smtp_host . ':' . $this->smtp_port, $errno, $errstr, $this->smtp_timeout, STREAM_CLIENT_CONNECT, $ctx ); // 注釋原來的代碼 // $this->_smtp_connect = @fsockopen($ssl.$this->smtp_host, // $this->smtp_port, // $errno, // $errstr, // $this->smtp_timeout);
!!!根據官網及多數網站建議使用hostname代替IP!!!