fsockopen():无法连接到ssl://smtp.gmail.com:465 [英] fsockopen(): unable to connect to ssl://smtp.gmail.com:465

查看:207
本文介绍了fsockopen():无法连接到ssl://smtp.gmail.com:465的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $ config = array(
'protocol'=>'smtp',
'smtp_host'=>'ssl://smtp.gmail。 com',
'smtp_port'=>'465',
'smtp_user'=> xxxxxxx@gmail.com,
'smtp_pass'=> xxxxxxx,/ /将其更改为您的
'mailtype'=>'html',
'charset'=>'utf8'
);

$ this-> load-> library(’email’,$ config);

$ this->电子邮件-> set_newline( \r\n);
$ this->电子邮件-> set_crlf( \r\n);

$ this->电子邮件-&from;($ config [’smtp_user']);
$ this-> email-&to; to($ email [’user_email’]);
$ this->电子邮件-> subject($ row [’tplsubject’]);
$ this->电子邮件->消息(html_entity_decode($ email_subject));
$ this->电子邮件-> send();

此代码无法正常显示错误


遇到PHP错误



严重性:警告



消息:fsockopen( ):无法连接到ssl://smtp.gmail.com:465
(无法找到套接字传输 ssl-您是否忘记在配置PHP时启用了
?)



文件名:libraries / Email.php



行号:1689



解决方案

这不是Codeigniter问题,而是与php设置相关的问题。可以在以下位置找到该问题的答案:无法找到套接字传输 ssl-您在配置PHP时是否忘记启用它?



一件事需要注意的是,在codeigniter中,您可以使用电子邮件配置文件来保存所有配置设置。 (因此,您不必每次都在控制器中定义它们)。您可以通过创建以下文件来做到这一点: application / config / email.php 然后可以使用设置填充该文件,如下所示:

 <?php定义('BASEPATH')或exit('不允许直接脚本访问'); 

$ config = array(
'protocol'=>'smtp',//'mail','sendmail'或'smtp'
'smtp_host'=> ;'your_host',
'smtp_port'=> your_port,
'smtp_user'=>'your_email',
'smtp_pass'=>'your_password',
' smtp_crypto'=>'security',//可以是'ssl'或'tls',例如
'mailtype'=>'html',//纯文本'text'邮件或'html'
'smtp_timeout'=>'4',//以秒为单位
'charset'=>'iso-8859-1',
'wordwrap'=> TRUE
);

每次加载库时( $ this-> load-> ; library('email'); )这些设置将自动加载。



此外,我建议您更改电子邮件密码立即,因为您在问题中写了凭据。


$config = array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.gmail.com',
    'smtp_port' => '465',
    'smtp_user' => "xxxxxxx@gmail.com", 
    'smtp_pass' => "xxxxxxx", // change it to yours
    'mailtype'  => 'html', 
    'charset'   => 'utf8'
);

$this->load->library('email',$config);

$this->email->set_newline("\r\n");
$this->email->set_crlf( "\r\n" );

$this->email->from($config['smtp_user']);
$this->email->to($email['user_email']);         
$this->email->subject($row['tplsubject']);
$this->email->message(html_entity_decode($email_subject));
$this->email->send();

This code not working its showing error

A PHP Error was encountered

Severity: Warning

Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?)

Filename: libraries/Email.php

Line Number: 1689

解决方案

This is not a codeigniter problem, but a php settings related problem. The answer to this question can be found here: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?

One thing to note is that in codeigniter you can use an e-mail config file, to hold all your config settings. (so you don't have to define them each time in a controller). You can do this by creating the file: application/config/email.php you can then fill this file with your settings, like this:

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

$config = array(
    'protocol' => 'smtp', // 'mail', 'sendmail', or 'smtp'
    'smtp_host' => 'your_host',
    'smtp_port' => your_port,
    'smtp_user' => 'your_email',
    'smtp_pass' => 'your_password',
    'smtp_crypto' => 'security', //can be 'ssl' or 'tls' for example
    'mailtype' => 'html', //plaintext 'text' mails or 'html'
    'smtp_timeout' => '4', //in seconds
    'charset' => 'iso-8859-1',
    'wordwrap' => TRUE
);

each time you load the library ($this->load->library('email');) these settings will be automatically loaded.

Also I recommend that you change your e-mail password immediately because you wrote your credentials in your question.

这篇关于fsockopen():无法连接到ssl://smtp.gmail.com:465的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆