duanqiao8925 2016-08-05 05:47
浏览 77

使用phpmailer错误从localhost xampp发送电子邮件

I have installed xampp.

I am trying phpmailer to send email to root@localhost.com

I have created root@localhost.com account in Microsoft Outlook.

When trying to send email from Outlook to root@localhost.com, It is working.

But when I am trying to send email from PHP script on localserver, Email is not getting sent..Getting error.

I am trying following PHP code.

<?php
require("class.phpmailer.php");
$mail = new PHPMailer();

$body = "Testing";
$sub = "Testing Email";
$mail->IsHTML(true); 
//$mail->IsSMTP();
$mail->Host = "localhost"; // SMTP server
$mail->From = "root@localhost.com"; // Your Full Email ID on your Domain
$mail->FromName = "Root User"; // Your name or Domain

$mail->AddAddress("root@localhost.com");

$mail->Subject = $sub;
$mail->Body = $body;
$mail->WordWrap = 50;
 if($mail->Send()){
    echo "Success";
}else{
    echo "Email Not Sent";
}
?>

I am getting the error

Email Not Sent

I have googled for this issue. Setup Mercury, made changes accordingly in php.ini and sendmail.ini files too...

But No Success...

  • 写回答

1条回答 默认 最新

  • dov11020 2016-08-05 08:18
    关注

    Outlook is just an e-mail client, so creating an account for root@localhost.com in it doesn't mean your computer can now process send mail requests.

    If you just need to test if your PHP is able to successfully post e-mails to a SMTP server, I suggest you use a tool like https://nilhcem.github.io/FakeSMTP/ (I do for development).

    In production, you set your code to use a proper SMTP server. eg: Send email using the GMail SMTP server from a PHP page

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大