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

时间:2011-07-20 23:21:25

标签: php email smtp

所以,我下载并安装了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"

3 个答案:

答案 0 :(得分:4)

smtp4dev的作者: 对不起,这可能是以下错误: http://smtp4dev.codeplex.com/workitem/6080

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

答案 1 :(得分:1)

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

;sendmail_from = postmaster@localhost

我认为应该是

sendmail_from = postmaster@localhost

这不是正确答案,但您可能还想查看php.ini上的其他评论标记=)

答案 2 :(得分:1)

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

[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