无法使用XAMPP

时间:2017-01-21 14:20:00

标签: php email xampp

我正在尝试使用localhost(XAMPP v3.2.1)发送电子邮件。为此,我需要重新配置php.inisendmail.ini文件。到目前为止,我所做的是,我在相应的文件中更改了以下内容。

php.ini我已更改为:

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"

sendmail.ini文件中我已更改

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

出于测试目的,我编写了一个index.php文件,如下所示:

<!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 \r\n";
         $header .= "senderMailId @gmail.com \r\n";
         $header .= "MIME-Version: 1.0\r\n";
         $header .= "Content-type: text/html\r\n";

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

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

   </body>
</html>

但结果显示无法发送消息。我不知道配置或代码是否有任何问题?请帮忙。

0 个答案:

没有答案