3
大家好我是新的PHP和HTML和麪臨問題: SMTP錯誤:無法連接到SMTP主機。郵件程序錯誤:SMTP錯誤:無法連接到SMTP主機。但在本地xampp中正常工作,並在服務器中出現錯誤。下面 代碼:SMTP錯誤:無法連接到SMTP主機。郵件錯誤:SMTP錯誤:無法連接到SMTP主機
<?php
$name = $_POST['name'];
$contact = $_POST['contact'];
$email = $_POST['email'];
$company = $_POST['company'];
$message = $_POST['message'];
$msg= " <strong>Name:</strong> $name <br /> <strong>Contact:</strong> $contact <br /> <strong>Email:</strong> $email <br /><strong>Company:</strong> $company <br /><strong>Message:</strong> $message";
require_once('mailer/class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPDebug = 0;
$mail->SMTPSecure = "ssl";
$mail->SMTPAuth = true;
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
//$mail->Username = "[email protected]";
//$mail->Password = "gmail pass";
//$mail->SetFrom('[email protected]', 'Pankaj U');
$mail->SetFrom($email);
$mail->AddReplyTo($email);
$mail->Subject = "Enquiry from Website";
$mail->MsgHTML($msg);
$address = "[email protected]";
$mail->AddAddress($address, $name);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
header('Location: thanks.html');
}
?>
你需要檢查你的防火牆 –
但在本地服務器工作正常? –