I have installed xampp.
I am trying phpmailer to send email to root@localhost.com
I have created root@localhost.com
account in Microsoft Outlook.
When trying to send email from Outlook to root@localhost.com
, It is working.
But when I am trying to send email from PHP script on localserver, Email is not getting sent..Getting error.
I am trying following PHP code.
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$body = "Testing";
$sub = "Testing Email";
$mail->IsHTML(true);
//$mail->IsSMTP();
$mail->Host = "localhost"; // SMTP server
$mail->From = "root@localhost.com"; // Your Full Email ID on your Domain
$mail->FromName = "Root User"; // Your name or Domain
$mail->AddAddress("root@localhost.com");
$mail->Subject = $sub;
$mail->Body = $body;
$mail->WordWrap = 50;
if($mail->Send()){
echo "Success";
}else{
echo "Email Not Sent";
}
?>
I am getting the error
Email Not Sent
I have googled for this issue. Setup Mercury, made changes accordingly in php.ini
and sendmail.ini
files too...
But No Success...
Outlook is just an e-mail client, so creating an account for root@localhost.com in it doesn't mean your computer can now process send mail requests.
If you just need to test if your PHP is able to successfully post e-mails to a SMTP server, I suggest you use a tool like https://nilhcem.github.io/FakeSMTP/ (I do for development).
In production, you set your code to use a proper SMTP server. eg: Send email using the GMail SMTP server from a PHP page