Code:
<?php
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->CharSet="utf-8";
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = '172.17.224.12'; // Specify main and backup SMTP servers
$mail->SMTPAuth = false; // Enable SMTP authentication
//$mail->Username = '***'; // SMTP username
//$mail->Password = '***'; // SMTP password
$mail->SMTPSecure = 'TLS'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 25; // TCP port to connect to
$mail->setFrom('itslt@example.com', 'Company.com');
$mail->addReplyTo('itslt@example.com');
$mail->addAddress('dichitslt@example.com'); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$bodyContent = '<h1>How to Send Email using PHP in Localhost by CodexWorld</h1>';
$bodyContent .= '<p>This is the HTML email sent from localhost using PHP script by <b>CodexWorld</b></p>';
$mail->SMTPDebug = 2;
$mail->Subject = 'Email from Localhost by CodexWorld';
$mail->Body = $bodyContent;
if(!$mail->send()) {
echo 'Message could not be sent.<br>';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>
When I run this code, it says message has been sent. However, when I look at my email, there's a notification saying that the email sent through my code was bounced back.
What could be the possible problem? was it the configuration in my code or was it the server?