简体   繁体   English

出现错误fsockopen():使用codeigniter电子邮件类发送电子邮件时,无法连接到smtp.googlemail.com:465(连接超时)

[英]getting error fsockopen(): unable to connect to smtp.googlemail.com:465 (Connection timed out) while sending email using codeigniter email class

I am new in codeigniter i am trying to send email using codeigniter email class but i am getting error fsockopen(): unable to connect to smtp.googlemail.com:465 (Connection timed out) i tried to solve this problem but no luck 我是Codeigniter的新手,我正在尝试使用Codeigniter电子邮件类发送电子邮件,但出现错误fsockopen():无法连接至smtp.googlemail.com:465(连接超时),我试图解决此问题,但是没有运气

public function signup()
{
    $this->form_validation->set_rules('email','Email','required|valid_email|is_unique[fbadmin.email]');
    $this->form_validation->set_error_delimiters("<p class='text-danger'>","</p>");
    if( $this->form_validation->run()==TRUE )
    {
        $data= $this->input->post();
        unset($data['submit']);
        //print_r($data);exit;
        $this->load->model('Fbadminmodel');
        if($this->Fbadminmodel->signup($data))
        {
            //$this->load->library('email');
            $config = array(
                'protocol'  =>'smtp',
                'smtp_host' =>'smtp.googlemail.com',
                'smtp_port' =>'465',
                'smtp_user' =>'anujk3313@gmail.com',
                'smtp_pass' =>'password',
                'mail_type' =>'html',
                'charset'   =>'utf-8'
                );
            //$this->email->initialize($config);
            $this->load->library('email', $config);
            $this->email->from('anujk3313@gmail.com','Anuj Kumar');
            $this->email->to($data);
            $this->email->message('www.haiviral.com');
            $this->email->set_newline("\r\n");

            if($this->email->send())
            {
                //$this->session->set_flashdata('feedback','Succefully Registred. Please verify your email');
                echo "mail send";
            }
            else
            {
                show_error($this->email->print_debugger());
            }
        }
        else
        {
            $this->load->view('fbadmin');
            $this->session->set_flashdata('feedback','Registration Failed');
        }
        //$this->session->flashdata('flash','Email Sent');
        $this->load->view('fbadmin');
    }
    else
    {
        echo validation_errors();
        $this->load->view('fbadmin');
    }
}

There are a few things that could be wrong. 有些事情可能是错误的。 First thing I would do is set your smtp_timeout setting: 我要做的第一件事是设置您的smtp_timeout设置:

$config = array(
    'smtp_timeout'=>'30', //<-- add this
    'protocol'  =>'smtp',
    'smtp_host' =>'smtp.googlemail.com',
    'smtp_port' =>'465',
    'smtp_user' =>'anujk3313@gmail.com',
    'smtp_pass' =>'password',
    'mail_type' =>'html',
    'charset'   =>'utf-8'
);

Next I would check is that your hosting allows you to access to port 465: 接下来,我将检查您的托管服务器是否允许您访问端口465:

$fp = fsockopen("smtp.gmail.com", 465, $errno, $errstr, 10);
if (!$fp)
    echo "smtp.gmail.com 465  -  $errstr   ($errno)<br>\n";

If it still doesn't work, I would try disabling gmail's 2-step verification. 如果仍然无法使用,我会尝试停用gmail的两步验证。

add ssl 添加ssl

$emailConfig = [
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.googlemail.com',
        'smtp_port' => 465,
        'smtp_user' => 'xxx@gmail.com',
        'smtp_pass' => 'xxx',
        'mailtype' => 'html',
        'charset' => 'iso-8859-1'
    ];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Codeigniter电子邮件无法在服务器fsockopen()中工作:无法连接至ssl://smtp.googlemail.com:465(连接被拒绝) - Codeigniter Email did not Working in Server fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Connection refused) 实施电子邮件CodeIgniter库时无法连接到ssl://smtp.googlemail.com:25 - Unable to connect to ssl://smtp.googlemail.com:25 while implementing email CodeIgniter lib 讯息:fsockopen():无法连接至ssl://smtp.googlemail.com:465(权限被拒绝) - Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Permission denied) Codeigniter无法连接到ssl://smtp.googlemail.com错误 - Codeigniter unable to connect to ssl://smtp.googlemail.com error 在Codeigniter中无法发送电子邮件-fsockopen():无法连接到ssl://smtp.gmail.com:465(连接被拒绝) - in Codeigniter Unable to send email - fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused) 消息:fsockopen():无法连接到ssl://smtp.gmail.com:465(连接超时) - Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection timed out) 如何解决错误:消息:fsockopen():无法连接到 ssl://smtp.gmail.com:465(连接被拒绝) - How to resolve the error: Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused) Laravel 3-错误:与smtp.gmail.com的连接:465超时 - Laravel 3 - error: Connection to smtp.gmail.com:465 Timed Out CodeIgniter电子邮件:fsockopen():无法连接到ssl://smtp.gmail.com托管中 - CodeIgniter email: fsockopen(): Unable to connect to ssl: //smtp.gmail.com in hosting [SMTP:无法连接套接字:fsockopen():无法连接至ssl://smtp.gmail.com:465(未知错误)(代码:-1,响应:)] - [SMTP: Failed to connect socket: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error) (code: -1, response: )]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM