开始试了很多次都发不成功,其实是因为 extension=php_openssl.dll 没有开启。Gmail使用的是ssl
$config['protocol'] = 'smtp'; $config['smtp_host'] = 'ssl://smtp.gmail.com'; $config['smtp_user'] = 'email@gmail.com'; $config['smtp_pass'] = '******'; $config['smtp_port'] = '465'; $config['smtp_timeout'] = '5'; $config['newline'] = "\r\n"; $config['crlf'] = "\r\n"; $this->email->initialize($config); $this->email->from('email@gmail.com', 'email'); $this->email->to('to@gmail.com'); $this->email->subject('subject'); $this->email->message('this is the mail content'); $this->email->send();
用ci的email类发邮件的时候发现来是出现这么一个错误:unable to connect to ssl (Unable to find the socket transport “ssl” - did you forget to enable it when you configured PHP?) 不过在php.ini里也没有发现ssl的扩展,去apache里倒是有个ssl的扩展,不过一打开就启动不成功(应该是需要配置一些东西才行),后来发现php文件夹下有openssl的扩展,只是安装不成功,于是上网搜原因,最后终于解决了,有用资料如下:
1,要想开启mcrypt支持,系统需要安装了libmcrypt.dll库。
这个一般用户是没有安装过的,但不用担心,PHP的windows发行包里已经给我们附带了此文件,在PHP压缩包的根目录下即可找到,然后将其复制到%system%/system32目录下即可。
2,要想开启OpenSSL支持,系统需要安装libeay32.dll和ssleay32.dll两个库。
如果你以前安装过OpenSSL,那么你的系统目录中应该已经存在这两个文件;如果没有安装,PHP的windows发行包里同样附带了这两个文件,将其复制到%system%/system32目录下即可。