如何配置 php.ini 以与 smtp4dev 一起使用?
因此,我下载并安装了 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
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.
我的猜测是,发生了“sendmail_from”错误,因为即使您在 php.ini 中明确定义了它,但您显然将其标记为注释(即 ; 行前面的字符)
我认为应该是
这不是真的正确答案,但您可能还想检查 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)
I think it should be
This is not really the correct answer, but you might also want to check other comment marks on your php.ini =)
伙计,我刚刚像这样修改了我的代码
看看这个视频,这对我有帮助
http://www.youtube.com/watch?v=IrYrI-ghxrE
Man, I just modified my code like this
Take a look into this video, that helped me
http://www.youtube.com/watch?v=IrYrI-ghxrE