我已经设法让我的 sendmail 功能在我的本地主机上工作,但是当我将它上传到我的虚拟主机时,我会看到一长串错误。我正在使用 gmail,它在本地运行良好。我认为这与 SSL 有关。这是我收到的错误:
A PHP Error was encountered
Severity: Warning
Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Connection timed out)
Filename: libraries/Email.php
Line Number: 1689
A PHP Error was encountered
Severity: Warning
Message: fwrite(): supplied argument is not a valid stream resource
Filename: libraries/Email.php
Line Number: 1846
这个列表还在继续。这是我发送电子邮件和使用的配置数组的函数:
$config = array(
'protocol' => "smtp",
'smtp_host' => "smtp.gmail.com",
'smtp_port' => 465,
'smtp_user' => "removed",
'smtp_pass' => "removed",
'mailtype' => "html",
'charset' => "iso-8859-1"
);
//generate a random key
$key = md5(uniqid());
//load email library and set config settings
$this->load->library("email", $config);//array("mailtype"=>"html")
$this->email->set_newline("\r\n");
$this->load->model("model_users");
$this->email->initialize($config);
我的主机是 123-reg.co.uk,我认为这与 SSL 有关。任何帮助都会非常感谢。