我是 CI 和 PHP 的新手。目前我正在使用 xammp 来运行 PHP、Apache 和 MySql。现在我正在尝试使用 CI 发送电子邮件。但我经常收到如下错误。
遇到 PHP 错误
严重性:警告
消息:fsockopen():无法连接到 ssl://smtp.googlemail.com:465(连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机无法连接回应。 )
文件名:库/Email.php
行号:1689
我用谷歌搜索了大约三个小时,但仍然没有找到解决方案。我已经openssl
在 Apache 中启用了“”。我想描述我的电子邮件控制器类的编码。
//电子邮件控制器'索引'函数的代码
$this->load->library('email');
$this->email->set_newline("\r\n");
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$config['protocol'] = 'smtp';
$config['smtp_port'] = 465;
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_user'] = "something@gmail.com";
$config['smtp_pass'] = "xxx";
$this->email->initialize($config);
$this->email->from('something@gmail.com', 'NayLinAung');
$this->email->to('something@gmail.com');
$this->email->subject('This is an email test');
$this->email->message("It is working, Great! You will be successful.");
if ($this->email->send())
{
echo "Email was successfully sent.";
}
else {
show_error($this->email->print_debugger());
}
当我将 'smtp' 更改为 'mail' 时,不会发生错误,但实际上并未发送电子邮件。此外,我关闭了我的 Windows 防火墙。
请为此错误提出任何解决方案。