php mail函数在win下的使用,以及配置win下的sendmail

mail函数在win里可以通过配置php.ini来正常使用注意:如果不是自己的服务器的话用其他方法发吧,方法多得是!
打开php.ini

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; sendmail_path = ""
; 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 =

设置SMTP,smtp_port,sendmail_from。分别是pop3服务器地址,端口号这两个一般默认,sendmail_from设置的是发件人邮箱
注意的是这里需要的pop3服务器是不需要身份验证的那种而且不能使用安全方式连接的。国内有些没有提供不验证服务的...在服务器上装上smtp组件就可以了,安装方法很多网上都有

如果不打算让本机成为smtp服务器,可以使用linux常用的sendmail,这样可以通过验证使用国内的一些服务器的pop3服务器,建议是qq或者foxmail个人感觉腾讯的速度和稳定都不错。

经测试目前163、新浪的SMTP无法使用,qq和foxmail可以用,其他没测试...

win下怎么配置呢

[mail function]
; For Win32 only.
; SMTP = localhost
; smtp_port = 25
; For Win32 only.
; sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "d:/soft/sendmail/sendmail.exe -t -i"
; 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 =

按上面的方式把前面说的三个选项前面都加上分号,把sendmail_path前面的分号去掉下载下面的文件:

sendmail压缩包

解压后找个地方放好,将里面sendmail.exe的地址填到sendmail_path并如上面所写增加-t -i参数(更多参数自己查吧)。
打开:sendmail.ini文件
修改里面的

smtp_server=smtp服务器地址
auth_username=邮箱登录名
auth_password=邮箱密码
force_sender=发件人地址全写

ok了mail函数可以正常使用了,注意如果iis使用cgi模式运行php的话用sendmail方法会出错,修改为ISAPI模式后一切正常了。

如果不是自己的服务器的话用其他方法发吧,方法多得是!

php

已有1条评论

  1. [...] http://www.xuandun.net/65/ 评论 (0) Trackbacks (0) 发表评论 Trackback [...]

添加新评论