我是网络开发的新手。我写了一个php代码来发送表单中的电子邮件,并将其托管在云端。每当我点击提交按钮时,我都会收到HTTP ERROR 500。phpmailer在尝试在云端上测试电子邮件时出现HTTP ERROR 500
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
# code...
$name = trim($_POST["fullname"]);
$email = trim($_POST["email"]);
$phone_no = trim($_POST["phone_num"]);
$partner_type = $_POST["Partner_type"];
if ($name == "" || $email == "" || $phone_no == " ") {
echo "please fill the required fields name , email , phone number";
}
if ($_POST["adds"] != "") {
echo "Bad form input";
exit;
}
require 'class.phpmailer.php';
$mail = new PHPMailer();
if (!$mail->ValidateAddress($email)) {
# code...
echo "Invalid Email Address";
exit;
}
$email_body = "";
$email_body .= "Name " . $name . "\n";
$email_body .= "Email " . $email . "\n";
$email_body .= "Phone Number " . $phone_no . "\n";
$email_body .= "Partner Type " . $partner_type . "\n";
$mail->setFrom($email, $name);
$mail->addAddress('[email protected]', 'gbubemi'); // Add a recipient
/**$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
**/
$mail->isHTML(false); // Set email format to HTML
$mail->Subject = 'Become a Partner ' . $name ;
$mail->Body = $email_body;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
} else {
echo 'Message has been sent';
}
header("location:index.php?status=thanks");
}
?>
请真的很沮丧,我需要帮助。谢谢。
检查你的PHP错误日志。 –
...请注册https://codereview.stackexchange.com/ - 您的代码不好。 – symcbean