简体   繁体   English

尽管PHP Mailer曾经可以工作,但在Go Daddy服务器上却无法工作吗?

[英]PHP Mailer not working on Go Daddy server despite it used to work?

I've setup a online quote builder on my website, essentially a large form that uses PHP Mailer to send the data to my email for me to read. 我已经在我的网站上设置了一个在线报价生成器,本质上是一个大型表单,使用PHP Mailer将数据发送到我的电子邮件中供我阅读。

The code used to work on the server just fine using PHP Mailer but for some reason returns an error within the $errors[] as noted further down in the code snippet is what is being outputted. 使用PHP Mailer可以在服务器上正常工作的代码很好,但是由于某些原因,在$ errors []中返回了错误,如代码片段中进一步指出的那样,正在输出。 I would really appreciate some advice as I have tried many things including changing port numbers etc... The form posts to my send-quote.php page and the code for this is: 我真的很感谢一些建议,因为我已经尝试了许多事情,包括更改端口号等。该表单发布到我的send-quote.php页面,其代码为:

    <?php

    session_start();

    require_once 'inc/libs/phpmailer/PHPMailerAutoload.php';


    $errors = [];

    if(isset($_POST['name'], $_POST['company'], $_POST['email'], $_POST['number'], $_POST['message'])) {

      $fields =  [
        'name' => $_POST['name'],
        'company' => $_POST['company'],
        'email' => $_POST['email'],
        'number' => $_POST['number'],
        'message' => $_POST['message']
      ];

      foreach($fields as $field => $data) {
        if(empty($data)) {
          $errors[] = 'The ' . $field . ' field is required.';
        }
      }

      if(empty($errors)) {

        $m = new PHPMailer;

        $m->isSMTP();
        $m->SMTPAuth = true;

        $m->Host = 'smtpout.europe.secureserver.net';
        $m->Username = 'my email goes here';
        $m->Password = 'my password goes here';
        $m->Port = 80;

        $m->isHTML();

        $m->Subject = 'Galaxy Radio Quote Builder';

        // Radio Advert type set

        $adverttype = "";
        if(isset($_POST['adverttype'])){
           $adverttype = $_POST['adverttype'];
        }

        // Advert features set

        $featureone = "";
        if(isset($_POST['featureone'])){
           $featureone = $_POST['featureone'];
        }
        $featuretwo = "";
        if(isset($_POST['featuretwo'])){
           $featuretwo = $_POST['featuretwo'];
        }
        $featurethree = "";
        if(isset($_POST['featurethree'])){
           $featurethree = $_POST['featurethree'];
        }

        // Additional services set

        $serviceone = "";
        if(isset($_POST['serviceone'])){
           $serviceone = $_POST['serviceone'];
        }
        $servicetwo = "";
        if(isset($_POST['servicetwo'])){
           $servicetwo = $_POST['servicetwo'];
        }
        $servicethree = "";
        if(isset($_POST['featurethree'])){
           $servicethree = $_POST['servicethree'];
        }

        // Advert duration set

        $advertduration = "";
        if(isset($_POST['advertduration'])){
           $advertduration = $_POST['advertduration'];
        }


        $m->Body = 'From: ' . $fields['name'] . ' ' . $fields['company'] . ' ' . $fields['number'] . ' (' . $fields['email'] . ')<p>' . $fields['message'] . '</p> ' . $adverttype . ' <br> ' . $featureone . ' <br> ' . $featuretwo . ' <br> ' . $featurethree . ' <br> ' . $serviceone . ' <br> ' . $servicetwo . ' <br> ' . $servicethree . ' <br> ' . $advertduration;

        $m->FromName = 'Galaxy Radio Website';

        $m->AddAddress('contact@galaxyradio.org', 'Galaxy Radio');

        if($m->send()) {
          header('Location: thanks.php');
          die();
        } else {
          $errors[] = "Sorry, could not send email. Try again later.";
        }

      }

    } else {
      $errors[] = "Something went wrong";
    }

    $_SESSION['errors'] = $errors;
    $_SESSION['fields'] = $fields;

    header('Location: advertise-with-us.php');

When I try submitting the form on the advertise page, the error pops up that says: Sorry, could not send email. 当我尝试在advertise页面上提交表单时,弹出错误消息: 对不起,无法发送电子邮件。 Try again later. 稍后再试。

Any suggestions as to why the error comes up instead of actually sending. 关于为什么出现错误而不是实际发送的任何建议。 The code you see - DID WORK but NOW doesn't?? 您看到的代码-可以工作,但现在不行?? I have't changed anything 我什么都没改变

This is the error that I'm getting using the debug mode: 这是我在使用调试模式时遇到的错误:

2016-09-04 20:59:40 SERVER -> CLIENT: 220 n1plsmtpa01-03.prod.ams1.secureserver.net :SMTPAUTH: ESMTP 
2016-09-04 20:59:40 CLIENT -> SERVER: EHLO www.galaxyradio.org 
2016-09-04 20:59:40 SERVER -> CLIENT: 250-n1plsmtpa01-03.prod.ams1.secureserver.net hello [46.252.205.133], secureserver.net 250-HELP 250-AUTH LOGIN PLAIN 250-SIZE 30000000 250-PIPELINING 250-8BITMIME 250-STARTTLS 250 OK 
2016-09-04 20:59:40 CLIENT -> SERVER: STARTTLS 
2016-09-04 20:59:40 SERVER -> CLIENT: 454 TLS not available due to temporary reason 
2016-09-04 20:59:40 SMTP ERROR: STARTTLS command failed: 454 TLS not available due to temporary reason 
2016-09-04 20:59:40 SMTP Error: Could not connect to SMTP host. 
2016-09-04 20:59:40 CLIENT -> SERVER: QUIT 
2016-09-04 20:59:40 SERVER -> CLIENT: 221 n1plsmtpa01-03.prod.ams1.secureserver.net :SMTPAUTH: closing connection 
2016-09-04 20:59:40 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

When dealing with similar situations with GD, there are 2 things that tend to be the/a problem. 使用GD处理类似情况时,有2件事往往是问题。

In many cases it doesnt even make sense for the fix to work but does indeed work. 在许多情况下,修复工作甚至没有任何意义,但确实有效。

1) They upgrade php and your version was switched and code becomes depreciated. 1)他们升级了php,并且您的版本已切换,并且代码已贬值。 They only show the last 3 releases as usable options. 它们仅将最后3个版本显示为可用选项。 (try to switch php version to lower one) (尝试将php版本切换到较低版本)

2) This one is by going to the Cpanel, select MX records and then the domain name (if more than one record in Cpanel) and select remote mail handler. 2)通过转到Cpanel,选择MX记录,然后选择域名(如果在Cpanel中有多个记录),然后选择远程邮件处理程序。

I can not tell you how many people suffer email issues through CPanel and people are unaware of number 2. Not even employees. 我无法告诉您有多少人通过CPanel遭受电子邮件问题,并且人们不知道第2位。甚至没有员工。

Either way good luck. 无论哪种方式,祝你好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM