首页 文章

在服务器上托管时,smtp电子邮件验证出错(LIVE)

提问于
浏览
0

目前网站已经在wordpress PHP中托管 . 在Codeigniter PHP中实现扩展现有网站中的不同模块有一个测验模型部分 . 实施该测验模型,在您继续游戏之前,您应该登录或注册 - 当用户注册并点击注册时,它会遇到错误..它会向您的电子邮件ID发送电子邮件验证链接 . 但它显示错误

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

代码在localhost上正在运行并正常运行,但在我实时托管它时却没有

你可以去查看link live

模型文件

public function sendEmail($receiver){
    $from = "";    //senders email address
    $subject = 'Verify email address';  //email subject

    //sending confirmEmail($receiver) function calling link to the user, 
inside message body
    $message = 'Dear User,<br><br> Please click on the below activation link 
 to verify your email address<br><br>
 <ahref=\'http://www.localhost/codeigniter/index.php/
Signup_Controller/confirmEail/'
 .md5($receiver).'\'>http://www.localhost/codeigniter/index.php/
Signup_Controller/confirmEmail/'. md5($receiver) .'</a><br><br>Thanks';



    //config email settings
    $config['protocol'] = 'smtp';
    $config['smtp_host'] = 'ssl://smtp.gmail.com';
    $config['smtp_port'] = '465';
    $config['smtp_user'] = $from;
    $config['smtp_pass'] = '';  //sender's password
    $config['mailtype'] = 'html';
    $config['charset'] = 'iso-8859-1';
    $config['wordwrap'] = 'TRUE';
    $config['newline'] = "\r\n"; 

    $this->load->library('email', $config);
    $this->email->initialize($config);
    //send email
    $this->email->from($from);
    $this->email->to($receiver);
    $this->email->subject($subject);
    $this->email->message($message);

    if($this->email->send()){
        //for testing
        echo "Check your email";
        return true;
    }else{
        echo "email send failed";
        return false;
    }

}

2 回答

  • 0

    我假设你没有在PHP配置中启用ssl . 检查PHP信息中的 ssl 状态?如果未启用,则在 php.ini 文件中进行以下更改:

    ;extension=php_openssl.dll
    

    改为

    extension=php_openssl.dll
    

    重新启动Apache服务器一次,然后更改它们 . 在您Cpanel上检查PHPINFO并验证更改是否已成功完成

  • 0

    如果您使用的是Gmail SMTP邮件,请转到您的Gmail帐户,并在连接的应用和网站下允许安全性较低的应用

    $config['smtp_user'] = 'example@gmail.com'; //your SMTP username
    $config['smtp_pass'] = 'gmail_log_in_password';  //your SMTP password
    

    更改

    $config['charset'] => 'iso-8859-1';
    

    $config['charset'] => 'utf-8';
    

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

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

相关问题