我在我的网站上设置了一个在线报价生成器,本质上是一个大型表单,它使用PHP Mailer将数据发送到我的电子邮件供我阅读。
用于在服务器上工作的代码很好地使用PHP Mailer但由于某种原因在$ errors []中返回错误,如下面的代码片段中所指出的那样是输出的内容。我真的很感激一些建议,因为我尝试过很多东西,包括更改端口号等等...表格发布到我的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');
当我尝试在广告页面上提交表单时,会弹出错误消息:抱歉,无法发送电子邮件。稍后再试。
有关为什么错误出现而不是实际发送的任何建议。你看到的代码 - DID工作,但现在不?我没有改变任何事情
这是我使用调试模式的错误:
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
答案 0 :(得分:0)
在处理与GD类似的情况时,有两件事情往往是/一个问题。
在许多情况下,修复工作甚至没有意义,但确实有效。
1)他们升级php,你的版本被切换,代码被折旧。它们仅显示最后3个版本作为可用选项。 (尝试将php版本切换为低版本)
2)这个是通过转到Cpanel,选择MX记录然后选择域名(如果Cpanel中有多个记录)并选择远程邮件处理程序。
我不能告诉你有多少人通过CPanel遭遇电子邮件问题,人们不知道2号。甚至不是员工。
无论哪种方式好运。