我正在使用wamp服务器和最新版本的CodeIgniter。我从php.ini中取消注释extension=php_openssl.dll
的行。我没有安装 AVG防病毒软件。但它不起作用。我在autoload.php中自动加载了电子邮件库
我的邮件发件人控制器:
<?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'] = 'my_email@gmail.com';
$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('nosisky@gmail.com', 'Mydomain');
$this->email->to('nosisky@gmail.com');
$this->email->subject('testing mail');
$this->email->message('testing mail server class');
$this->email->send();
echo $this->email->print_debugger();
}
}
这是我打印CodeIgniter电子邮件调试程序时收到的错误消息的一部分。
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 :(得分:0)
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://just127.justhost.com',
'smtp_port' => 465,
'smtp_user' => 'user@gmail.com',
'smtp_pass' => 'yourpassword',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);