PHP表单 - PHP Mailer无法发送到@ Gmail.com

时间:2013-09-11 19:18:21

标签: php

我们的网站上有一个已经工作多年的PHP表单。当用户填写表单时,向我们发送详细信息,并向他们发送电子邮件,然后将用户重定向到“感谢”页面。但是,如果用户将其电子邮件地址设置为@ gmail.com,则表单无法发送,则不会显示感谢页面。

这真是奇怪。我们正在使用PHPMailer并验证表单是否已使用以下方式发送:

 if($mail->Send()) {
      $mailsent = true;

如果用户输入@ hotmail.com或@ yahoo.com,一切都很好。但输入@ gmail.com和$ mailsent总是假的。

在这种情况下问题是什么?在我看来,我们的网站托管与Gmail的SMTP连接失败。这看起来是对的吗?

以下是代码:

<?php
error_reporting(E_ALL); 
ini_set("display_errors", 1);

  $name = '';
  $email = '';
  $mailsent = false;
  $referer = '';

  if(isset($_POST['name'])){

  include('phpmailer/class.phpmailer.php');

    $name     = $_POST['name'];
    $email    = $_POST['email'];
    $subject = 'Quote request  from ' . $name;
    $body = 'A quote request has been received from a user with following details:' . "\n\n" .
            "Name: $name \n" .
            "Email: $email \n" .
            "----------------------------------------------------\n\n" .
            "Place: UK".

    $body .= "\n----------------------------------------------------\n\n";
    $body .= "Refering: ".$referer." \n";


    $mail = new PHPMailer();
    $mail->Subject  = $subject;
    $mail->From     = $email;
    $mail->FromName = $name;
    $mail->Body = $body;
    $mail->AddAddress("dean@example.com", "Example");

    if($mail->Send()) {
      $mailsent = true;

    } else {
      $error[] = 'There was some error. Please try later.';
    }

  }
?>

0 个答案:

没有答案