【问题标题】:sendmail.exe opens on sending mailsendmail.exe 在发送邮件时打开
【发布时间】:2014-08-22 06:13:31
【问题描述】:

我实际上是使用 sendmail 的新手,但我已经阅读了很多关于此的内容,并且只将我重定向到使用 PHPmailer、swiftmailer 等……但是如果没有基础知识,理解起来非常复杂。所以我决定尝试简单,这就是我所拥有的。

我已经配置了我的 php.ini:

[mail function]
smtp_port = 465
sendmail_path="C:\wamp\sendmail\sendmail.exe -t"
mail.add_x_header = On

还有我的 sendmail.ini:

[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=
error_logfile=error.log
debug_logfile=debug.log
auth_username=mygmail@gmail.com
auth_password=mypassword
hostname=localhost

我有这个 PHP 代码:

$to      = 'mygmail@gmail.com';
$message = $_POST['message'];
$email = $_POST['email'];
$contact_num = $_POST['contact_number'];
$headers = 'From:'.'$email' . "\r\n" .'$contact' . "\r\n" .
'Reply-To: mygmail@gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $message, $headers);

但是,当我单击提交按钮时,sendmail.exe 会出现,但没有任何反应。当我检查 error.log 时,它说:

14/07/01 23:23:48 : Connection Closed Gracefully.

【问题讨论】:

  • 您使用的是什么服务器?你如何运行你的服务器?
  • 您找到解决方案了吗?我以管理员身份打开 XAMPP,之后 sendmail.exe 没有打开,邮件功能返回 true,但 gmail 帐户没有收到邮件

标签: php gmail sendmail.exe


【解决方案1】:

这部分是帖子的复制和粘贴:Sendmail Wamp Php

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

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

    如果您使用 gmail,您需要创建新密码“您的 应用程序专用密码”

如果还是不行的话(我的回答)

确保服务器(或 IDE)以管理员身份运行,方法是:

1) 右键单击​​程序(例如服务器、ide、命令提示符)并单击“以管理员身份运行”

2) 或者右键程序>属性>兼容性>勾选以管理员身份执行

例如,如果您在内置服务器中使用 PHP,请以管理员身份运行命令提示符并正常启动服务器

C:\wamp\bin\php\php5.5.12\php.exe -S localhost:80 -t C:\Users\path\to\rootFolder

当然可以根据需要更改文件路径。

编辑:这可能是您遇到的错误 https://bugs.php.net/bug.php?id=44994

【讨论】:

    【解决方案2】:

    解决方案是设置 sendmail.ini 和 php.ini

    您需要与您的 isp 进行沟通,以了解有什么开放的 smtp 服务器,他们中的大多数都有一个,并且大多数时候它就像 smtp.yourisp.com。

    您也可以使用您自己的电子邮件服务器或现有电子邮件地址设置 smtp,这将需要其他设置,例如特定的 smtp 服务器、端口号、强制发送邮件为实际邮件、用户名、密码和大多数时间 ssl

    php.ini

    ; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury  SMTP = smtp.yourisp.mu  smtp_port = 25
    
    ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = postmaster@yourisp.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:\xampp\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"
    

    确保 php 和 sendmail 以管理员身份运行似乎是个好主意,但这并没有解决我的问题。

    sendmail.ini 中的解决方案

    smtp_server = smtp.yourisp.com
    
    ; smtp port (normally 25)
    
    smtp_port=25
    
    ; SMTPS (SSL) support
    ;   auto = use SSL for port 465, otherwise try to use TLS
    ;   ssl  = alway use SSL
    ;   tls  = always use TLS
    ;   none = never try to use SSL
    
    smtp_ssl=none
    

    不要使用 smtp_ssl = auto 这就是导致我的错误的原因,只需根据您的规范将其设置为 ssl tls 或 none服务器

    【讨论】:

      【解决方案3】:

      确保 XAMPP 以管理员身份运行。通过右键单击它并单击“以管理员身份运行”来执行此操作。那为我修好了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-02-05
        • 2010-10-23
        • 1970-01-01
        • 2012-12-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多