|
最近研究uchome,使用在线发邮件的功能,但是测试了"通过 PHP 函数的 sendmail 发送(推荐此方式)"怎么都没用,因为本人现在用的是iis+php环境,怎么调试都没有用,经过研究之后搞定,分享一下教大家在自己服务器上配置sendmail。很多php的网站例如Discuz的论坛和各种phpCMS的网站都用到。
9 z8 v3 j# V0 D首先你需要先到从http://glob.com.au/sendmail/下载sendmail.zip文件,点此可以直接下载噢,然后把它解压到如D:\php\sendmail\目录下。 _! l6 c+ B) ^: @" S2 x& g! K
然后打开php.ini文件,找到下面这段代码# q/ t& m7 X! n2 j
- [mail function]
. y9 h" a9 ~2 o5 w - ; For Win32 only. 9 k& K: u! H7 s
- SMTP = localhost & I8 d- Y3 K" Y4 I7 _7 J+ F, d- ^
- smtp_port = 25
, H: f9 }/ Y9 ?) t8 o - ; For Win32 only. 0 v" t* Y8 F: Y
- ;sendmail_from = me@example.com 3 R, p% r3 |1 H% g" N
- ; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
4 B' X$ T9 f+ g7 C - ; sendmail_path = ""
6 C9 ^3 h% ]" J - ; Force the addition of the specified parameters to be passed as extra parameters
6 i. B. a" B% z+ g; w2 F/ o - ; to the sendmail binary. These parameters will always replace the value of
9 ~& h4 |, l- E( ~% u. f - ; the 5th parameter to mail(), even in safe mode.
* g# s4 J# o, Y' Q9 p( F$ V4 E6 G - ;mail.force_extra_parameters =
复制代码 默认情况下是以本机做为邮件服务器,这里我们需要借用sendmail来发送邮件,用sendmail来配置如用qq、163的邮箱来发送(一般都是以这种方式)所以我们需要把所有的选项都注销,即把SMTP = localhost和smtp_port = 25前面加上";"然后把sendmai_path=""前面的";"删掉,改为sendmai_path="d:\php\sendmail\sendmail.exe -t",改完后的即是 , m6 f3 F. C; @$ G
- [mail function]
3 l9 e$ u0 g* V* F+ ?4 g - ; For Win32 only.
3 W* R8 U8 W. b& g( ~" v# H - ;SMTP = localhost
$ n8 K2 m* d/ } F/ } - ;smtp_port = 25
1 y5 x2 o% P" I0 u2 j- @ - ; For Win32 only. $ I4 L0 d8 @4 M7 n- d1 H w' {
- ;sendmail_from = me@example.com
, e( Y9 m1 {; T: _0 t9 B' W - ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). - {8 e- R# a' b$ h A* L, L8 E
- sendmail_path = "d:\php\sendmail\sendmail.exe -t"
/ H7 _1 V1 s! g. @ - ; Force the addition of the specified parameters to be passed as extra parameters
2 V" |5 x2 x# \0 R; y$ c) X- J - ; to the sendmail binary. These parameters will always replace the value of
! ]6 K. Y- ~5 q- J! F - ; the 5th parameter to mail(), even in safe mode. 8 m2 i) h+ Y& d9 n$ F$ ~
- ;mail.force_extra_parameters =
复制代码
7 _6 R f$ w, J3 X0 `, \7 {* D8 s6 ?注意以上只需要开启sendmail_path即可,然后保存
- c5 K2 y2 R5 }" j* E O/ K+ w3 W
; A) z' L5 [; }5 w8 o1 c1 `1 w接着修改sendmail目录下的sendmail.ini文件,主要填的内容有以下几项 - A. T2 G* t5 O
- smtp_server=smtp服务器地址(如 smtp.ym.163.com) , p; P/ Y1 Q }/ E) h2 C; k
- auth_username=邮箱登录名(如 info@xxxx.com) 1 i3 R6 b7 u, e" n
- auth_password=邮箱密码(如 xxxxxx) : _, T2 T; D) ]
- force_sender=发件人地址全写(如 info@xxxx.com)
复制代码 另外还有一项
# l4 a- Y% f" g' | ~* M f$ _- ; auto = use SSL for port 465, otherwise try to use TLS
复制代码 8 y0 j; c. _' U6 ^* t. v6 t2 k
把前面的";"删除,即开启SSL安全登录选项即可
% F: O5 e* r! G" Y6 o8 M2 T- H2 [8 r# \9 U
以上四项正确填写修改完成后保存,然后重启IIS即可正常使用。 0 L- b% o% p4 x0 U7 a' M
% o$ U8 B* q$ z如果不能发送邮件,检查下端口是不是被屏蔽了,杀毒软件是不是设置了禁止发送邮件等
7 \+ I% d5 J* q6 Y, _2 K: G; e# e" b0 E. v8 H
|
|