I am using PHPMailer, it seems works but not received any message from them I don't know what is wrong.
I'm using tester email address from this site. Mail Tester
here is my code.
contact-form.php
<?php
$msg = '';
if (array_key_exists('email', $_POST)) {
date_default_timezone_set('Etc/UTC');
require 'php-mailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'localhost';
$mail->Port = 25;
$mail->setFrom('noreply@****.com', 'Sender Name');
$mail->addAddress('[email protected]', 'Recipient Name');
if ($mail->addReplyTo($_POST['email'], $_POST['name'])) {
$mail->Subject = 'Message from '.$_POST['name'];
$mail->isHTML(true);
$mail->CharSet = 'UTF-8';
$mail->Body = <<<EOT
Email: {$_POST['email']}
Name: {$_POST['name']}
Message: {$_POST['message']}
EOT;
if(!$mail->send()) {
$arrResult = array ('response'=>'error');
}
$arrResult = array ('response'=>'success');
echo json_encode($arrResult);
} else {
$arrResult = array ('response'=>'error');
echo json_encode($arrResult);
}
}
?>
PHPMailerAutoload.php
<?php
function PHPMailerAutoload($classname)
{
$filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
if (is_readable($filename)) {
require $filename;
}
}
if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
spl_autoload_register('PHPMailerAutoload', true, true);
} else {
spl_autoload_register('PHPMailerAutoload');
}
} else {
function __autoload($classname)
{
PHPMailerAutoload($classname);
}
}
When I click Send Message I can see "Your message has been sent to us" but I won't receive any message from them.