Php CodeIgniter can';不要在VPS上发送电子邮件
我目前正在使用CodeIgniter开发RESTAPI。我得到了一个使用gmail smtp的电子邮件验证系统,该系统在本地主机上运行良好。但是当我把它上传到VPS服务器时,它就不工作了 这是我的代码:Php CodeIgniter can';不要在VPS上发送电子邮件,php,codeigniter-3,Php,Codeigniter 3,我目前正在使用CodeIgniter开发RESTAPI。我得到了一个使用gmail smtp的电子邮件验证系统,该系统在本地主机上运行良好。但是当我把它上传到VPS服务器时,它就不工作了 这是我的代码: protected function send_confirmation($email, $hash){ $config = array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.gma
protected function send_confirmation($email, $hash){
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => 'xxx@gmail.com',
'smtp_pass' => 'xxx',
'mailtype' => 'html',
'charset' => 'utf-8',
'crlf' => "\r\n",
'newline' => "\r\n"
);
$this->load->library('email', $config);
$mail = $this->email;
$mail->from('no-reply@example.com', 'Example.com');
$mail->to($email);
$mail->subject('Email Verification');
$encodemail = urlencode($email);
$message = 'Some messages here.';
$mail->message($message);
$mail->send();
}
还请注意,我使用的是PHP7.2,我尝试了许多配置,但在VPS服务器上似乎没有任何效果。试试这些
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.gmail.com', #changed
'smtp_port' => 587, #changed
'smtp_user' => 'xxx@gmail.com',
'smtp_pass' => 'xxx',
'mailtype' => 'html',
'charset' => 'utf-8',
'newline' => "\r\n"
);
或者使用我想你的谷歌smtp_主机是smtp.gmail.com,试着删除ssl://if 如果你使用谷歌gmail smtp发送邮件,你得到的回复总是请给出一些评论,或者,如果有帮助的话,将其标记为绿色并向上投票,这是感谢所有编程人员的最好方式。在我发布这个问题后,这个问题已经解决了。事实证明,这与我们使用的电子邮件有关,但我记不起它是什么了。很抱歉放弃这个问题这么久。