我創建了一個新頁面聯繫我們 我遇到了這個錯誤遇到麻煩。郵件不發送在PHP?
警告:電子郵件()[function.mail]:無法連接在 到郵件服務器 「localhost」 的端口25,驗證 「SMTP」 和 「SMTP_PORT」 在php.ini或 使用的ini_set設置()在上線41 contact_me.php
我的PHP文件是
<?php
// check if fields passed are empty
if(empty($_POST['fname']) ||
empty($_POST['lname']) ||
empty($_POST['phone']) ||
empty($_POST['email']) ||
empty($_POST['dateTime']) ||
empty($_POST['heading']) ||
empty($_POST['companyName']) ||
empty($_POST['address']) ||
empty($_POST['postalCode']) ||
empty($_POST['city']) ||
empty($_POST['country']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$phone = $_POST['phone'];
$dateTime = $_POST['dateTime'];
$heading = $_POST['heading'];
$companyName = $_POST['companyName'];
$address = $_POST['address'];
$postalCode = $_POST['postalCode'];
$city = $_POST['city'];
$country = $_POST['country'];
$message = $_POST['message'];
$email_address = $_POST['email'];
// create email body and send it
$to = '[email protected]'; // PUT YOUR EMAIL ADDRESS HERE
$email_subject = "Modern Business Contact Form: $fname"; // EDIT THE EMAIL SUBJECT LINE HERE
$email_body = "You have received a new message from your website's contact form.\n\n"."Here are the details:\n\nFirst Name: $fname\n\nLast Name: $lname\n\nPhone: $phone\n\nContact Date Time:\n$dateTime\n\nHeading: $heading\n\nCompany Name: $companyName\n\nAddress: $address\n\nPostal Code: $postalCode\n\nCity: $city\n\nCountry: $country\n\nMessage: $message\n\nEmail ID: $email_address";
$headers = "From: [email protected]\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
請讓我知道什麼是問題。
你需要在本地主機上運行SMPT服務器以使其工作,並且應該在php,ini文件 – Pooya
中提及SMTP服務器的參數。首先,您應該獲得[PHPMailer]的副本(https://github.com/PHPMailer/PHPMailer )。然後再次嘗試使用它。 – Zapp
我住在這個網站不是本地的 –