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