I tried all the steps which are prompted in win server 2012 r2 relates answer including its related answers and particular PHPMailer too.
But still, I'm running with the same issue. Additionally, have checked about port 25 is running no firewall issue here.
If anyone can help me, it's really appreciated.
NOTE:
Win server 2012 r2 relates answer
PHPMailer answer
server fault answer Thanks
UPDATE
//To test is via basic mail function
/*
mail("from_to_email@example.com", "Test Subject", "Test Message");
*/
//To Test via PHPMailer
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/phpmailer/phpmailer/src/Exception.php';
require 'vendor/phpmailer/phpmailer/src/PHPMailer.php';
require 'vendor/phpmailer/phpmailer/src/SMTP.php';
//PHPMailer Object
$mail = new PHPMailer;
//From email address and name
$mail->From = "from_email@example.com";
$mail->FromName = "Full Name";
//To address and name
$mail->addAddress("to_email@example.com"); //Tried $mail->addAddress("to_email@example.com", "test name"); and third param too.
//Send HTML or Plain Text email
$mail->isHTML(true); //Tried with false too.
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->SMTPDebug = 3;
$mail->SMTPSecure = 'ssl';
// optional
// used only when SMTP requires authentication
$mail->SMTPAuth = true;
$mail->Username = SMTP_EMAIL_HERE;
$mail->Password = SMTP_PASS_HERE;
$mail->Subject = "Subject Text";
$mail->Body = "<i>Mail body in HTML</i>";
$mail->AltBody = "This is the plain text version of the email content";
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
Even, I tried my SMTP credential via online SMTP Tool and it's working fine but above code isn't.
NOTE: I verified about PHP/Apache modules availability and it's there so no issue about the module.