2017-06-15 100 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