I got some problem when I try to use PHPMailer code. This code still works on Oct/2017 but not work since Dec/2017 to now. I tried to find other similar question but time seems too odd, or it doesn't help. I didn't change any code inside since I finished. but error appeared when time passed. And I got this error:
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
when I try to find it on troubleshotting, it says it might cause by localhost. Here is my code:
function mailsend($email,$accepter,$title,$content){
include_once("../lib/PHPMailer/PHPMailerAutoload.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->CharSet = "utf-8";
$mail->Encoding = "base64";
$mail->WordWrap = 50;
$mail->Username = "myaccount@gmail.com";
$mail->Password = "mygmail_account_password";
$mail->From = "sender@gmail.com";
$mail->FromName = "sender_name";
$mail->Subject = $title;
$mail->IsHTML(true);
$mailList =
array(
array($email,$accepter)
);
foreach ($mailList as $receiver) {
$mail->AddAddress($receiver[0], $receiver[1]);
$mail->Body = $content;
if($mail->Send()) {
// echo"<script>alert('success_sended');</script>";
} else {
echo $mail->ErrorInfo;
echo "<br>";
}
$mail->ClearAddresses();
}
}
If I want to change some code to make it work again where can I start? Cheers for taking a look.