duankuang7928 2019-02-15 06:36
浏览 307

Codeigniter电子邮件无法在服务器fsockopen()中工作:无法连接到ssl://smtp.googlemail.com:465(连接被拒绝)

Please help me in codeigniter Email, I had many tries but it did not work, Its working On localhost but did not work on server.

ERROR:

A PHP Error was encountered

Severity: Warning

Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Connection refused)

Filename: libraries/Email.php

Line Number: 2069

Backtrace:

File: /home/b4ger7ik8el2/public_html/account/application/controllers/Welcome.php Line: 105 Function: send

File: /home/b4ger7ik8el2/public_html/account/index.php Line: 315 Function: require_once

$config = array(
                        'protocol' => 'smtp',
                        'smtp_host' => 'ssl://smtp.googlemail.com',
                        'smtp_port' => 465,
                        'smtp_user' => 'Email', // change it to yours
                        'smtp_pass' => 'Pasword', // change it to yours
                        'mailtype' => 'html',
                        'charset' => 'iso-8859-1',
                        'wordwrap' => TRUE
                    );

                    $message =  "
                                <html>
                                <head>
                                    <title>Verification Code</title>
                                </head>
                                <body>
                                    <h2>Thank you for Registering.</h2>
                                    <p>Dear:".$this->input->POST('firstname')."</p>
                                    <p>Email: ".$this->input->POST('user_email')."</p>
                                    <p>Please click the link below to activate your account.</p>
                                    <h4><a href='".base_url()."welcome/activate/".$email=$this->input->POST('user_email')."/'>Activate My Account</a></h4>
                                </body>
                                </html>
                                ";

                    $this->load->library('email', $config);
                    $this->email->set_newline("
");
                    $this->email->from($config['smtp_user']);
                    $this->email->to($this->input->POST('user_email'));
                    $this->email->subject('Signup Verification Email');
                    $this->email->message($message);

                    //sending email
                    if($this->email->send()){
                        $this->session->set_flashdata('Success','Your Account Has Been Created Please Check your email and verify your account..!');
                    }
                    else{
                        $this->session->set_flashdata('message', $this->email->print_debugger());

                    }
  • 写回答

2条回答 默认 最新

  • dongmu2026 2019-02-15 06:42
    关注

    You just need to remove the SSL part from your SMTP string in the config array,

    config = array(
                   'protocol' => 'smtp',
                    'smtp_host' => 'smtp.googlemail.com',
                    'smtp_port' => 465,
                    'smtp_user' => 'Email', // change it to yours
                    'smtp_pass' => 'Pasword', // change it to yours
                    'mailtype' => 'html',
                    'charset' => 'iso-8859-1',
                    'wordwrap' => TRUE
                        );
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog