【问题标题】:How to configure php.ini to work with smtp4dev?如何配置 php.ini 以使用 smtp4dev?
【发布时间】:2011-07-20 23:21:24
【问题描述】:

所以,我下载并安装了 smtp4dev。

当我尝试在我的 php 文件中发送邮件时:

mail('localhost', "Hey there", "no");

我从 php.ini 收到一个错误,抱怨 sendmail_from 没有声明。

我尝试声明它:

sendmail_from = postmaster@localhost

这使 php 保持沉默,但仍然无法正常工作 - 尝试加载页面 30 秒,然后出现另一个错误。致命错误:超过 30 秒的最大执行时间。

我必须如何配置 php.ini 才能让它工作?

php.ini

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

; 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\apache\logs\php_mail.log"

【问题讨论】:

    标签: php email smtp


    【解决方案1】:

    smtp4dev 的作者在这里: 抱歉,这可能是以下错误: http://smtp4dev.codeplex.com/workitem/6080

    您的 php.ini 看起来正确。使用 CodePlex 的最新版本再试一次,应该没问题。

    【讨论】:

      【解决方案2】:

      我的猜测是“sendmail_from”错误的发生是因为即使您已经在 php.ini 中明确定义了它,但您显然将其标记为注释(即 ; 行前面的字符)

      ;sendmail_from = postmaster@localhost
      

      我觉得应该是的

      sendmail_from = postmaster@localhost
      

      这不是真正的正确答案,但您可能还想检查 php.ini 上的其他注释标记 =)

      【讨论】:

        【解决方案3】:

        伙计,我刚刚这样修改了我的代码

        [mail function]
        ; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
        SMTP = localhost
        smtp_server = localhost
        smtp_port = 25
        

        看看这个对我有帮助的视频 http://www.youtube.com/watch?v=IrYrI-ghxrE

        【讨论】:

        • php.ini 中仍然不存在此变量。没有smtp_server 变量。正确的变量简称为 SMTP 您在回答中已经提到的内容。
        • 尝试在 SMTP 下方手动添加它,我认为它应该可以工作。问候
        猜你喜欢
        • 2013-10-12
        • 2011-05-04
        • 2016-03-10
        • 1970-01-01
        • 2018-09-20
        • 1970-01-01
        • 2018-12-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多