【问题标题】:Sendmail configuration changed in XAMPP 1.8.0, can't send local mails anymoreXAMPP 1.8.0 中更改了 Sendmail 配置,无法再发送本地邮件
【发布时间】:2012-08-05 10:45:51
【问题描述】:

我刚刚从 XAMPP 1.7.3 升级到 1.8.0,这包括在我重新安装开发环境时进行了很多更改(PHP 5.4 等)。 无论如何,现在一切正常,除了 Sendmail。 之前,您在 sendmail.ini 中有这样的配置:

#defaults
logfile "C:\XAMPP\sendmail\sendmail.log"

## A freemail service example
account Hotmail
tls on
tls_certcheck off
host smtp.live.com
from [exampleuser]@testmail.loc
auth on
user [exampleuser]@hotmail.com
password [examplepassword]

# Set a default account
account default : Hotmail

加上php.ini中的一些值:

sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"
SMTP = localhost
smtp_port = 25

现在一切看起来都大不相同了(而且旧的配置不起作用),一个例子: http://pastebin.com/M83bNmJw

一个小的 php 邮件脚本:

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
 $to = "someone@hotmail.com";
 $subject = "Hi!";
 $body = "Hi,\n\nHow are you?";
 if (mail($to, $subject, $body)) {
   echo("<p>Message successfully sent!</p>");
  } else {
   echo("<p>Message delivery failed...</p>");
  }
?>

消息传递失败... 我想我太愚蠢了,无法更改正确的内容,它根本行不通,而且我的日志文件中几乎没有错误,所以我什至不知道从哪里开始。

【问题讨论】:

    标签: email xampp sendmail.exe


    【解决方案1】:
     #GMAIL mit XAMPP 1.8.1 und sendmail
    [CODE]
    [sendmail]
    ; HOTMAIL
    smtp_server=smtp.gmail.com
    smtp_port=25
    smtp_ssl=tls
    tls_certcheck off
    error_logfile=error.log
    debug_logfile=debug.log
    auth_username= xxxx.xxxx@gmail.com
    auth_password=xxxxxxx
    
    
     this settings in php.ini   
     [mail function]
        ; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
        ; SMTP = smtp.gmail.com
        ; smtp_port = 25
    
        ; For Win32 only.
        ; http://php.net/sendmail-from
        sendmail_from = xxxx.xxxx@gmail.com
    
        ; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesC:\xampp) fakemail and mailtodisk do not work correctly.
        ; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.  
    
        ; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
        sendmail_path = "\"C:\sendmail\sendmail.exe\" -t"
    
        ; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:\xampp\mailoutput folder
        ;sendmail_path = "C:\xampp\mailtodisk\mailtodisk.exe"
    
        ; Force the addition of the specified parameters to be passed as extra parameters
        ; to the sendmail binary. These parameters will always replace the value of
        ; the 5th parameter to mail(), even in safe mode.
        ;mail.force_extra_parameters =
    
        ; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
        mail.add_x_header = Off
    
        ; Log all mail() calls including the full path of the script, line #, to address and headers
        mail.log = "C:\xampp\php\logs\php_mail.log"
    

    【讨论】:

      【解决方案2】:

      我看到在 1.8.0 中,默认会通过 mailtodisk.exe 发送邮件。你已经在你的 PHP 配置文件中启用了它,但是你禁用了 mailtodisk.exe 吗?

      此外,您需要确保将 sendmail.ini 中的 smtp_server 设置为 localhost

      我自己找到了这个解决方案,所有使用 PHP 发送的邮件都可以正常工作。

      【讨论】:

      • Michael,我现在找到了一个很好的例子(链接在另一篇文章中),最大的问题是,我在 sendmail.ini 中使用了 sendmail-tag 两次(是的,我'我太愚蠢了,无法评论所有内容)。
      【解决方案3】:

      我的 xampp 是 1.8.2,窗口为 8.1

      在 php.ini 中

          smtp_port = 587
          sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"
          mail.add_x_header=Off
      

      在 sendmail.ini 中

          smtp_server=smtp.gmail.com
          smtp_port=587
          smtp_ssl=auto
          error_logfile=error.log
          auth_username=xxaayy@gmail.com
          auth_password=kskcmhlrjr
      
          pop3_server=
          pop3_username=
          pop3_password=
      
          force_sender=xxaayy@gmail.com
          force_recipient=
          hostname=
      

      要为 gmail "auth_password" 帐户创建新密码 "Your application-specific passwords",请查看 [此处][1]

      然后按照以下步骤操作:

      问题是 sendmail 必须以管理员身份运行。这是帮助任何人解决我的情况的解决方案。

      1. 右键单击 sendmail.exe
      2. 属性
      3. 兼容性
      4. 更改所有用户的配置
      5. 作为 Windows XP SP 3 执行
      6. 以管理员身份执行
      7. 测试邮件

        $to = "aaaaaaa@domain.com";
        $subject = "Hi!";
        $body = "Hi,\n\nHow are you?";
        $headers = "From: xxaayy@gmail.com" . "\r\n";
        if (mail($to, $subject, $body, $headers)) {
           echo ("Message successfully sent!");
        } else {
           echo ("Message delivery failed...");
        }
        

      【讨论】:

        【解决方案4】:

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2016-09-03
          • 2013-05-28
          • 1970-01-01
          • 2013-12-18
          • 2015-04-23
          • 1970-01-01
          • 2013-04-25
          • 2014-09-03
          相关资源
          最近更新 更多