2017-06-15 59 views
0

我正在使用最新版本的CodeIgniter的wamp服務器。我已取消註釋從我的php.ini中說extension=php_openssl.dll的行。我沒有安裝AVG防病毒。但它不起作用。我的電子郵件庫在我autoload.php自動加載在wamp服務器上用codeigniter發送郵件時出錯

我的郵件發送者控制:

<?php 
defined('BASEPATH') OR exit('No direct script access allowed'); 

class Testmail extends CI_Controller { 

public function index() 
{ 
    //configure email settings 
    $config['protocol'] = 'sendmail'; 
    $config['smtp_host'] = 'ssl://smtp.gmail.com'; //smtp host name 
    $config['smtp_port'] = '465'; //smtp port number 
    $config['smtp_user'] = '[email protected]'; 
    $config['smtp_pass'] = 'correct_password'; //$from_email password 
    $config['mailtype'] = 'html'; 
    $config['charset'] = 'iso-8859-1'; 
    $config['wordwrap'] = TRUE; 
    $config['newline'] = "\r\n"; //use double quotes 
    $this->email->initialize($config); 

    //send mail 
    $this->email->from('[email protected]', 'Mydomain'); 
    $this->email->to('[email protected]'); 
    $this->email->subject('testing mail'); 
    $this->email->message('testing mail server class'); 
    $this->email->send(); 
    echo $this->email->print_debugger(); 
} 


} 

這是我當我打印的笨電子郵件調試程序錯誤消息的一部分。

A PHP Error was encountered 

Severity: Warning 

Message: fsockopen(): SSL operation failed with code 1. OpenSSL Error 
messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown 
protocol 

Filename: libraries/Email.php 

Line Number: 2063 
+0

的可能的複製的[Gmail的fsockopen():SSL操作與笨和XAMPP失敗的錯誤(https://stackoverflow.com/questions/34570064/gmail-fsockopen-ssl-operation-failed-error-with -codeigniter-and-xampp) – Joe

+0

我按照概述的步驟操作,但不工作。 – dealwap

回答

0

我用下面的代碼。它工作得很好。將協議更改爲smtp。也可以嘗試在您的代碼中刪除或包含ssl://

$config = array(
     'protocol' => 'smtp', 
     'smtp_host' => 'ssl://just127.justhost.com', 
     'smtp_port' => 465, 
     'smtp_user' => '[email protected]', 
     'smtp_pass' => 'yourpassword', 
     'mailtype' => 'html', 
     'charset' => 'iso-8859-1' 
); 
+0

這樣做後,我從電子郵件調試器中得到'421服務器繁忙的太多連接。 – dealwap

+0

我編輯了我的答案。請按照這個。 – kazinayem2011

相關問題