I am trying to send email from PHP using SMTP but every time I am getting emails in my spam. I searched on google and got some solution but still I am getting email in spam. Would you help me in this?
//$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'abc@gmail.com'; // SMTP username
$mail->Password = '***'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption,'ssl' also accepted
$mail->Port = 587; //Set the SMTP port number - 587 for authenticated TLS
$mail->setFrom('abc@gmail.com', 'admin'); //Set who the message is to be sent from
$mail->addReplyTo('abc@gmail.co', 'First Last'); //Set an alternative reply-to address
$mail->addAddress($to, 'user'); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Hello';
$mail->Body = "<html>
<head>
<title>HTML email</title>
</head>
<body>
<a href='/changepassword.php?user_id=" .$User_id1."'>Create your password here</a>
</body>
</html>";
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}