I'm very new to PHP. I downloaded a phpmailer script (with files) from here -> phpmailer
I'm using XAMPP and I located the files in:
\htdocs\QMS\phpmailer
My php script resides in: \htdocs\QMS\
I get the message that the mail was sent, but I do not see anything in my inbox, trash, or spam. I tried other email addresses and still nothing.
Here's the code: (*email addresses and names have been masked with "xxx")
<?php
require_once('phpmailer/class.phpmailer.php');
$mail = new PHPMailer(); // defaults to using php "mail()"
$mail->AddReplyTo("xxxx@mycompany.com","xxx xxx");
$mail->SetFrom('xxxx@mycompany.com","xxx xxx');
$mail->AddReplyTo('xxxx@mycompany.com","xxx xxx');
$body = "This is a test... It works!";
$address = "xxxx@mycompany.com";
$mail->AddAddress($address, "xxx xxx");
$mail->Subject = "A subject line here";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAttachment("images/phpmailer.gif"); // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
The way you have setup your PHPMailer, it would require an SMTP server running on your localhost to send the messages. If you don't have an SMTP server running on your localhost, then you can use an external SMTP server to relay the messages through. To know more about PHPMailer, Please refer below for a working example of how to do this with PHPMailer.
.
I know I'm late to the party, but if someone stumbles here and is looking for a quick solution for trying e-mails on your localhost, you can use this nice freeware to run a fake SMTP server on your computer which will let you 'see' the e-mails a real SMTP server would have received and sent (it doesn't actually send anything).
http://nilhcem.github.io/FakeSMTP/
Super useful during development and testing.