0
我試圖從PHP本地主機發送電子郵件。這是我的代碼:PHP郵件程序無法發送電子郵件
<?php
// $email and $message are the data that is being
// posted to this page from our html contact form
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
require_once('class.phpmailer.php');
require 'PHPMailerAutoload.php';
require 'class.smtp.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "localhost"; // specify main and backup server
$mail->SMTPAuth = false; // turn on SMTP authentication
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = ""; // SMTP password
$mail->Port = 25;
$mail->SMTPSecure = '';
$mail->From = $email;
$mail->AddAddress("[email protected]", "Brad Markle");
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = "You have received feedback from your website!";
$mail->Body = $message;
$mail->AltBody = $message;
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
當我運行此代碼時,它顯示「消息已發送」,但它實際上並未發送消息。我的問題是什麼?
如果你使用GMAIL發送郵件,你應該檢查連接的參數。您應該使用SSL連接到SMTP。 –
如果確實沒有要求,那麼嘗試刪除併發送一個簡單的PHP郵件功能的電子郵件。如果可行,那麼Gmail SMTP連接就會出現問題 – Avinash