<?php
class EmailModel extends CI_Model{
public function email(){
require 'Email Files/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'Google account username';
$mail->Password = 'Google account Password';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->addAddress('abc@gmail.com');
$mail->setFrom('abc@gmail.com');
$mail->Subject = 'Test';
$mail->Body = 'Testing';
if($mail->send()) {
echo 'Message has been sent';
} else {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
}
}
?>
我正在使用Github库来发送电子邮件。 当我var_dump($ mail);它显示数组中的所有数据。 现在,此代码显示错误:&#34; SMTP connect()失败&#34;
答案 0 :(得分:1)
我也有这个问题。请执行以下步骤
答案 1 :(得分:0)