我正在尝试使用Core HP中的SMTP服务器发送电子邮件。我得到一个空白页面没有显示任何错误。谁能帮我吗?我做错了什么?也无法检查问题!
<?php ob_start();
if(isset($_POST['submit_contact'])) {
require 'PHPMailer/PHPMailerAutoload.php';
$to = "abc@gmail.com";
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$txt = $_POST['comment'];
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->IsHTML(true);
$mail->Username = "abc@gmail.com";
$mail->Password = "password1@3";
$mail->SetFrom('$email');
$mail->Subject = $subject;
$mail->Body = $txt;
$mail->AddAddress($to);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
}
?>
答案 0 :(得分:0)
是你的源代码,位于public_html文件夹中? 在这种情况下,你必须包括如下
require 'aaa/PHPMailer/PHPMailerAutoload.php';