|
最近研究uchome,使用在线发邮件的功能,但是测试了"通过 PHP 函数的 sendmail 发送(推荐此方式)"怎么都没用,因为本人现在用的是iis+php环境,怎么调试都没有用,经过研究之后搞定,分享一下教大家在自己服务器上配置sendmail。很多php的网站例如Discuz的论坛和各种phpCMS的网站都用到。& H3 O! c' Q" o& a1 @5 P) I
首先你需要先到从http://glob.com.au/sendmail/下载sendmail.zip文件,点此可以直接下载噢,然后把它解压到如D:\php\sendmail\目录下。, M4 P/ R, V! @' Y7 n% n
然后打开php.ini文件,找到下面这段代码
K* b2 \- w& j# D7 Z( _- [mail function]
; j) G1 a( ], N$ n3 j% g5 j - ; For Win32 only.
- O* \; @3 c7 m M, R! z1 f' x# b3 R - SMTP = localhost
- V8 H/ t( n0 f$ u4 e2 f6 s - smtp_port = 25 ! T9 b* n0 e4 d+ Q6 W$ D% M
- ; For Win32 only.
5 h5 }1 D9 f, F9 [ - ;sendmail_from = me@example.com 3 l6 F, X4 ?% _; n
- ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ( \ V, z" A! u3 V' C/ N
- ; sendmail_path = ""
; t7 ^0 }$ n1 ]3 M' X - ; Force the addition of the specified parameters to be passed as extra parameters
# \1 l* _+ n4 O - ; to the sendmail binary. These parameters will always replace the value of + j- s6 E, \/ d
- ; the 5th parameter to mail(), even in safe mode. : I" ^0 I1 U% W$ x1 \4 q' o
- ;mail.force_extra_parameters =
复制代码 默认情况下是以本机做为邮件服务器,这里我们需要借用sendmail来发送邮件,用sendmail来配置如用qq、163的邮箱来发送(一般都是以这种方式)所以我们需要把所有的选项都注销,即把SMTP = localhost和smtp_port = 25前面加上";"然后把sendmai_path=""前面的";"删掉,改为sendmai_path="d:\php\sendmail\sendmail.exe -t",改完后的即是
9 o' [# B' }. {- n6 e- [mail function]
9 @1 e- p6 x, A" S# |& A- f) h" C8 V - ; For Win32 only. 8 I8 Z# k7 r5 ?4 Z$ m5 `1 p* f
- ;SMTP = localhost
) p U& d) _" s, V* d - ;smtp_port = 25
- G# y+ s& z8 p$ m: z5 X) j% ? - ; For Win32 only. % J. q& d, @/ X. H! u
- ;sendmail_from = me@example.com i) r. M# K! p% ^
- ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). 3 X% `0 r- N! U, f3 R
- sendmail_path = "d:\php\sendmail\sendmail.exe -t"
6 ?# S! \7 I y - ; Force the addition of the specified parameters to be passed as extra parameters
: f/ n" E% S. }+ h - ; to the sendmail binary. These parameters will always replace the value of
# N) F9 b4 H h6 S6 N4 W - ; the 5th parameter to mail(), even in safe mode. * ~4 h, y- e* m
- ;mail.force_extra_parameters =
复制代码 % g$ f# o+ p0 V
注意以上只需要开启sendmail_path即可,然后保存
; F2 V C3 D$ O( @! R# q+ ]+ e8 L0 A/ r9 R8 D! t/ u3 G4 k$ |" N
接着修改sendmail目录下的sendmail.ini文件,主要填的内容有以下几项
" X: A* C( @8 ~/ b8 N2 h- smtp_server=smtp服务器地址(如 smtp.ym.163.com)
* w6 N* H$ [* v) p& y1 q - auth_username=邮箱登录名(如 info@xxxx.com) u( T9 L2 h9 p, `# X
- auth_password=邮箱密码(如 xxxxxx)
; ]* n8 x/ P6 j - force_sender=发件人地址全写(如 info@xxxx.com)
复制代码 另外还有一项
- V3 c& X5 W5 l: J) b [ }" W- ; auto = use SSL for port 465, otherwise try to use TLS
复制代码 $ [7 U3 m( j/ V) G5 X
把前面的";"删除,即开启SSL安全登录选项即可
* _: H7 n+ R/ B
7 ?" P) G! P1 E: n$ _/ m以上四项正确填写修改完成后保存,然后重启IIS即可正常使用。 2 j4 I4 n; Q& L& m3 Y
! N% [* y6 D; u: p6 U如果不能发送邮件,检查下端口是不是被屏蔽了,杀毒软件是不是设置了禁止发送邮件等
# C3 w* a ~4 p+ \. c0 P4 k# ~9 Q) c: l: u8 ~8 I
|
|