我正在尝试通过核心Php发送邮件,我创建了一个文件email.php
并在其中包含PHPMailer_v5.1
..这是我的PHP代码,
<?php if($_POST){
$email = $_REQUEST['email'] ;
$comments = $_REQUEST['comments'] ;
$phone = $_POST['telephone'] ;
$name = $_REQUEST['name'] ;
$mail = new PHPMailer();
$mail->Host = "localhost";
$mail->From = "scorpion.schizo@gmail.com";
$mail->FromName = "Showket";
$mail->AddAddress("manusurya9139@gmail.com");
$mail->Subject = "Feedback form results";
$mail->Body="
Name: $name
Email: $email
Telephone: $telephone
Comments: $comments";
$mail->WordWrap = 50;
if(!$mail->Send())
{
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
}
else
{
echo 'Thank you for your feedback.';
}
}
?>
当我发布此表单时,它给了我正确的消息感谢您的反馈。但我没有收到消息。我需要配置其他任何内容吗?
答案 0 :(得分:2)
尝试将Gmail设为SMTP
<?php if($_POST){
$email = $_REQUEST['email'] ;
$comments = $_REQUEST['comments'] ;
$phone = $_POST['telephone'] ;
$name = $_REQUEST['name'] ;
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = "ssl://smtp.gmail.com:465"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "scorpion.schizo@gmail.com"; // SMTP username
$mail->Password = "password"; // SMTP password
$mail->Host = "localhost";
$mail->From = "scorpion.schizo@gmail.com";
$mail->FromName = "Showket";
$mail->AddAddress("manusurya9139@gmail.com");
$mail->Subject = "Feedback form results";
$mail->Body="
Name: $name
Email: $email
Telephone: $telephone
Comments: $comments";
$mail->WordWrap = 50;
if(!$mail->Send())
{
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
}
else
{
echo 'Thank you for your feedback.';
}
}
?>
答案 1 :(得分:0)
运行“sendmail -bp”以检查队列中是否有任何内容。另外,请检查运行您的网络服务器的用户的电子邮件文件夹,看看您是否有任何无法送达的通知。