在XAMPP 1.8.0中更改了Sendmail配置,无法再发送本地邮件

时间:2012-08-08 10:29:25

标签: email xampp sendmail.exe

我刚刚从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>");
  }
?>

邮件传递失败... 我想我改变正确的东西太愚蠢了,它只是赢了工作,而且我的日志文件中几乎没有出错,所以我甚至不知道从哪里开始。 / p>

4 个答案:

答案 0 :(得分: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"

答案 1 :(得分:0)

我在1.8.0中看到,默认情况下会通过mailtodisk.exe发送邮件。您已在PHP配置文件中启用它,但是您是否已禁用mailtodisk.exe?

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

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

答案 2 :(得分:0)

我的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”,您需要创建新密码“您的应用程序专用密码”,请查看[此处] [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...");
    }
    

答案 3 :(得分:-1)