目前网站已经托管在wordpress PHP中。在Codeigniter PHP中实现以扩展现有网站中的不同模块,有一个测验模型部分。实施该测验模型,在继续游戏之前,您应该登录或注册 - 当用户注册并单击注册时,它遇到了错误。它会将电子邮件验证链接发送到您的电子邮件 ID。但它显示错误
Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465
(Connection refused)
代码在本地主机上运行并正常工作,但当我实时托管它时没有
您可以去查看链接
模型文件
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'] = "rn";
$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;
}
}
我假设您没有在PHP配置中启用SSL。 在您的 PHP 信息中检查您的SSL状态?如果未启用,则在php.ini
文件中进行以下更改:
;extension=php_openssl.dll
将其更改为
extension=php_openssl.dll
重新启动您的 apache 服务器一次,您可以进行这些更改。 在Cpanel上检查PHPINFO并验证更改是否已成功完成
如果您使用的是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);