PHPMailer发送但未收到

时间:2018-01-30 07:52:18

标签: phpmailer

我正在使用PHPMailer,它似乎有效,但没有从它们收到任何消息 我不知道出了什么问题。

我正在使用此网站的测试人员电子邮件地址。 Mail Tester

这是我的代码。

接触form.php的

tvText.setTextSize(0, tvText.getTextSize() - 2.0f);

PHPMailerAutoload.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('web-0zlvk@mail-tester.com', '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);

  }
 }
?>

当我点击发送消息时,我可以看到&#34;您的消息已发送给我们&#34;但是我没有收到他们的任何消息。

1 个答案:

答案 0 :(得分:0)

首先,您使用的是旧版本 - get the latest

您正在使用SMTP到localhost,这意味着您正在运行本地邮件服务器。这是一个很好的配置,但意味着您的脚本只知道向本地服务器的传送,而不是超出其最终目的地。要了解之后会发生什么,您需要查看邮件服务器日志,通常是/var/log/mail.log之类的地方。

相关问题