duanfei1975 2017-01-21 14:19
浏览 27

无法使用XAMPP发送邮件

I am trying to send email using localhost (XAMPP v3.2.1). For that I need to reconfigure php.ini and sendmail.ini file. So far what I have done is, I changed the following in the corresponding files.

In php.ini I have changed to :

extension=php_openssl.dll (I Remove the semicolon from beginning) 
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = my-gmail-id@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

And in sendmail.ini file I have changed

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=my-gmail-id@gmail.com
auth_password=my-gmail-password
force_sender=my-gmail-id@gmail.com

For Testing purpose I have written an index.php file like this:

<!DOCTYPE html>
<html>

   <head>
      <title>Sending HTML email using PHP</title>
   </head>

   <body>

      <?php
         $to = "testMailId@gmail.com";
         $subject = "This is subject";

         $message = "<b>This is HTML message.</b>";
         $message .= "<h1>This is headline.</h1>";

         $header = "From:senderMailId @gmail.com 
";
         $header .= "senderMailId @gmail.com 
";
         $header .= "MIME-Version: 1.0
";
         $header .= "Content-type: text/html
";

         $retval = mail ($to, $subject, $message, $header);

         if($retval == true ) {
            echo "Message sent successfully...";
         } else {
            echo "Message could not be sent...";
         }
      ?>

   </body>
</html>

But the result is showing that message could not be sent. I don’t know if there is any wrong with configuration or code? Please help.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 2024-五一综合模拟赛
    • ¥15 如何将下列的“无限压缩存储器”设计出来
    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口