PHPMailer没有错误,但电子邮件卡在队列中

时间:2014-01-06 18:11:54

标签: php iis smtp phpmailer

我有一个表单,它使用PHPMailer将表单内容发送到电子邮件地址。这是脚本:

<?php

require_once('assets/PHPMailer/class.phpmailer.php');

$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$job = $_POST['job'];
$file = $_FILES['fileUpload']['name'];


$mail = new PHPMailer();


$mail->From = "jobform@website.com";
$mail->FromName  =  "Job Form";
$mail->AddAddress("receivingaddress@website.com","Job Form");

$mail->WordWrap = 50;  

$mail->Subject = "Job Form";
$mail->Body="
            First Name: $first_name
            Last Name: $last_name
            Phone Number: $phone
            Email: $email
            Job: $job";

$maxsize = 2 * 1024 * 1024;
$types = array('application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document');


if ((isset($_FILES['fileUpload']) && $_FILES['fileUpload']['error'] == UPLOAD_ERR_OK) && $_FILES['fileUpload']['size'] < $maxsize && in_array( $_FILES['fileUpload']['type'], $types)) {
    $mail->AddAttachment($_FILES['fileUpload']['tmp_name'],
                         $_FILES['fileUpload']['name']);
} else {

  header("Refresh: 3; URL=http://www.interactive360.com/join-our-team.php");
  echo 'Please upload a PDF or Word Document that is under 2MB';
  exit();

}

$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email)) {
      header("Refresh: 3; URL=http://www.website.com/join-our-team.php");
      echo 'Please enter a valid email address';
      exit();
}

if($first_name == '') {
      header("Refresh: 2; URL=http://www.website.com/join-our-team.php");
      echo 'Please enter your first name';
      exit();
}

if($last_name == '') {
      header("Refresh: 2; URL=http://www.website.com/join-our-team.php");
      echo 'Please enter your last name';
      exit();
}


if(!$mail->Send())
{
   echo 'Message was not sent.';
   echo 'Mailer error: ' . $mail->ErrorInfo;
}
else
{
  header("Refresh: 2; URL=http://www.website.com/");
   echo 'Thank you for your feedback.';
}

?>

当我提交表单时,我会收到成功消息(感谢您的反馈。)但是电子邮件从未显示在我的收件箱中。我的站点在Windows Server 2012上运行。我安装了SMTP服务器,允许所有计算机通过虚拟服务器进行中继。

当我检查inetpub&gt; mailroot&gt; Badmail文件夹,没有“坏”的电子邮件。而是将电子邮件保存到inetpub&gt; mailroot&gt;队列文件夹。这是否意味着存在连接问题?是否有特定的smtp设置需要更改或我应该修改我的PHP脚本?

0 个答案:

没有答案