所以这是我的代码,似乎它没有捕获我的“内容”输入字段,这不是空的顺便说一句,但是我得到了这个错误
无法发送消息.Mailer错误:消息正文空白
<?php
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'intrepid.servers.prgn.misp.co.uk'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'secret@secret.co'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->setFrom($_POST["userEmail"], $_POST["userName"]);
$mail->addAddress('myemailforreceivingemails@gmail.com'); // Add a recipient
$mail->addReplyTo($_POST["userEmail"], $_POST["userName"]);
if(is_array($_FILES)) {
$mail->AddAttachment($_FILES['attachmentFile']['tmp_name'],$_FILES['attachmentFile']['name']);
}
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $_POST["subject"];
$mail->Body = $_POST["content"];
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
这是来自我的index.php文件
function sendContact() {
var valid;
valid = validateContact();
if(valid) {
$.ajax({
url: "contact_mail.php",
type: "POST",
data: new FormData(this),
contentType: false,
cache: false,
processData:false,
success: function(data){
$("#mail-status").html(data);
},
error: function(){}
});
}
}