如何配置 php.ini 以与 smtp4dev 一起使用?

发布于 2024-11-25 23:02:37 字数 1290 浏览 0 评论 0原文

因此,我下载并安装了 smtp4dev。

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

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

我从 php.ini 收到错误,抱怨未声明 sendmail_from 。

我尝试声明它:

sendmail_from = postmaster@localhost

That made php Silent, but still does not work - 尝试加载页面 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"

So, I downloaded and installed smtp4dev.

When i try sending a mail in my php file:

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

i get an error from php.ini, complaining that sendmail_from isnt declared.

I tried declaring it:

sendmail_from = postmaster@localhost

That made php silent, but still doesnt work - tries to load the page for 30 seconds and then another error. Fatal error: Maximum execution time of 30 seconds exceeded.

How must i configure php.ini for it to work?

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"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

以歌曲疗慰 2024-12-02 23:02:37

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

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

Author of smtp4dev here:
Sorry, that was probably the following bug:
http://smtp4dev.codeplex.com/workitem/6080

Your php.ini looks correct. Try again with the latest release from CodePlex and you should be fine.

女中豪杰 2024-12-02 23:02:37

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

;sendmail_from = postmaster@localhost

我认为应该是

sendmail_from = postmaster@localhost

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

My guess is that the "sendmail_from" error happened because even though you have explicitly defined it in your php.ini, you apparently mark it as a comment (That ; char in front of the line)

;sendmail_from = postmaster@localhost

I think it should be

sendmail_from = postmaster@localhost

This is not really the correct answer, but you might also want to check other comment marks on your php.ini =)

玻璃人 2024-12-02 23:02:37

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

[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

Man, I just modified my code like this

[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

Take a look into this video, that helped me
http://www.youtube.com/watch?v=IrYrI-ghxrE

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文