【发布时间】:2018-09-18 15:14:17
【问题描述】:
我想使用 PHPMailer 发送电子邮件,我正在使用 Codeigniter
public function check_email(){
$response = array('error' => false);
$email = $this->input->post('email');
$check_email = $this->fp_m->check_email($email);
if($check_email){
$this->load->library('phpmailer_library');
$mail = $this->phpmailer_library->load();
$mail->setFrom('from@example.com', 'Mailer');
$mail->addAddress($email);
$mail->isHTML(true);
$mail->Subject = "Reset Password";
$mail->Body = "
Hi,<br><br>
In order to reset your password, please click on the link below:<br>
<a href='
http://example.com/resetPassword.php?email=$email
'>http://example.com/resetPassword.php?email=$email</a><br><br>
Kind Regards,<br>
Kokushime
";
if($mail->send()){
$response['error'] = false;
$response['message'] = "The Email Sent. Please Chect Your Inbox";
}else{
$response['error'] = true;
$response['message'] = "There's Something wrong while sending the message". $mail->ErrorInfo;
;
}
}else{
$response['error'] = true;
$response['message'] = 'The email that you entered is not associated with admin account';
}
echo json_encode($response);
}
但它给了我错误Could not instantiate mail function。 顺便说一句,我没有使用 SMTP,因为我不需要它.. 我希望你能帮助我:)
【问题讨论】:
-
请记住,PHP 具有调试模式,因此您可以查看故障发生的确切位置。但是这个主机可能无法发送邮件。但可以肯定的是,您必须对此进行更多调试。
-
这个错误通常意味着你没有安装本地邮件服务器,就像 PHPMailer 文档说的那样。
标签: php codeigniter phpmailer