【问题标题】:Error occuring in smtp email verification while hosting it on server (LIVE)在服务器上托管 smtp 电子邮件验证时发生错误(实时)
【发布时间】:2017-07-11 08:53:56
【问题描述】:

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

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

代码在本地主机上运行并正常工作,但在我实时托管时却没有

你可以去查看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;
    }

}

【问题讨论】:

  • 显示您发送电子邮件的代码
  • @YadhuBabu 请检查

标签: php codeigniter live email-verification


【解决方案1】:

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

;extension=php_openssl.dll

改成

extension=php_openssl.dll

重启你的apache服务器一次,你就改变了这些。 在您的 Cpanel 上检查 PHPINFO 并验证更改是否已成功完成

【讨论】:

    【解决方案2】:

    如果您使用的是 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);
    

    【讨论】:

      猜你喜欢
      • 2021-03-23
      • 2015-04-16
      • 1970-01-01
      • 2014-02-22
      • 1970-01-01
      • 2013-09-06
      • 1970-01-01
      • 2012-01-12
      • 1970-01-01
      相关资源
      最近更新 更多