0
我在本地主機上有一個非常簡單的HTML CSS和javaScript網站。我想做一個非常簡單的聯繫表單。通常我通過插件使用WordPress來實現這一點,並且從未在普通網站上手動創建電子郵件。phpMailer - localhost當前無法處理此請求。
我已經從:https://github.com/PHPMailer/PHPMailer/blob/master/class.phpmailer.php下載了class.phpmailper.php文件,並將其放入我的網站的根目錄。
在我接觸的形式我做一個簡單的
if(isset($_POST['submit'])){
}
,並嘗試發送電子郵件。我已經把我用在我的WordPress網站,相同的SMTP細節但是當我點擊提交頁面只是說:
網站名稱頁面無法正常工作
envirofuel,重新設計目前無法處理此請求。
HTTP 500錯誤
這是當表單提交時執行的代碼:
if(isset($_POST['submit'])){
require_once('class.phpmailer.php');
$subject = 'test';
$body_of_your_email = 'hello test body';
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug = 0;
// 0 = no output, 1 = errors and messages, 2 = messages only.
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = ""; // sets the prefix to the servier
$mail->Host = "I PUT MY SMTP HOST HERE"; // sets Gmail as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL
$mail->Username = "I PUT MY USERNAME HERE"; // Gmail username
$mail->Password = "I PUT MY PASSWORD HERE"; // Gmail password
$mail->CharSet = 'windows-1250';
$mail->SetFrom ('[email protected]', 'Example.com Information');
$mail->AddBCC ('[email protected]', 'Example.com Sales Dep.');
$mail->Subject = $subject;
$mail->ContentType = 'text/plain';
$mail->IsHTML(false);
$mail->Body = $body_of_your_email;
// you may also use $mail->Body = file_get_contents('your_mail_template.html');
$mail->AddAddress ('I PUT MY PERSONAL EMAIL HERE', 'Matthew');
// you may also use this format $mail->AddAddress ($recipient);
if(!$mail->Send())
{
$error_message = "Mailer Error: " . $mail->ErrorInfo;
} else
{
$error_message = "Successfully sent!";
}
}
任何想法?
錯誤500是服務器級錯誤。日誌說什麼?你有沒有運行調試工具? – Webomatik
你已經將你的代碼基於一個過時的PHPMailer示例。更新它。您收到的錯誤(將在您的Web服務器日誌中)可能是您尚未加載SMTP類。 – Synchro