|
|
最近研究uchome,使用在线发邮件的功能,但是测试了"通过 PHP 函数的 sendmail 发送(推荐此方式)"怎么都没用,因为本人现在用的是iis+php环境,怎么调试都没有用,经过研究之后搞定,分享一下教大家在自己服务器上配置sendmail。很多php的网站例如Discuz的论坛和各种phpCMS的网站都用到。- d9 F0 F9 Y: D2 v/ s5 c
首先你需要先到从http://glob.com.au/sendmail/下载sendmail.zip文件,点此可以直接下载噢,然后把它解压到如D:\php\sendmail\目录下。% y0 N3 e$ }( A
然后打开php.ini文件,找到下面这段代码. T& y/ ?1 ^. l1 z. N5 R: b+ \
- [mail function]
! m/ T1 K: G7 D- e - ; For Win32 only.
! w1 L: r: E/ i" i# t! \* c - SMTP = localhost A! s. E0 `1 O9 _& b
- smtp_port = 25
1 R4 Y1 K2 A5 G+ g - ; For Win32 only. ; H+ {4 E F- b
- ;sendmail_from = me@example.com ! u! o3 g' @) f9 h% A
- ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). % ]$ f8 _, r2 I3 r5 x4 Q, C1 P4 ^! n! D- y
- ; sendmail_path = "" , ]2 _1 i9 ~. a! t. {( Y& f
- ; Force the addition of the specified parameters to be passed as extra parameters
. a7 X! Y; X9 s5 P6 Q- _ - ; to the sendmail binary. These parameters will always replace the value of * V! _, ~) q0 N% a8 D
- ; the 5th parameter to mail(), even in safe mode. 6 C$ P6 A: W2 }* b0 Z h& g% k
- ;mail.force_extra_parameters =
复制代码 默认情况下是以本机做为邮件服务器,这里我们需要借用sendmail来发送邮件,用sendmail来配置如用qq、163的邮箱来发送(一般都是以这种方式)所以我们需要把所有的选项都注销,即把SMTP = localhost和smtp_port = 25前面加上";"然后把sendmai_path=""前面的";"删掉,改为sendmai_path="d:\php\sendmail\sendmail.exe -t",改完后的即是
7 Z) m) O5 j+ ~# \- [mail function] # D0 W9 S- O5 a, A N! _
- ; For Win32 only.
" K# ^. c, P m) y$ e' I( H - ;SMTP = localhost " T2 W% j! [1 |2 j C, G6 R
- ;smtp_port = 25 ) W4 F$ E, }( R8 u- e% r8 y
- ; For Win32 only. ; O* L8 l0 ~6 n6 H1 k) p, H/ Q
- ;sendmail_from = me@example.com 3 w6 X3 @9 j+ g2 j4 A8 s8 j
- ; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; I: ^# d Y0 i# N& U) l k$ W. [7 X; [ - sendmail_path = "d:\php\sendmail\sendmail.exe -t"
7 G$ q, j; \3 D- t - ; Force the addition of the specified parameters to be passed as extra parameters
. u. z- w1 c) M% C - ; to the sendmail binary. These parameters will always replace the value of
# N0 @, z( Z& b# {1 ^) X. [( g - ; the 5th parameter to mail(), even in safe mode. ' u# d0 A$ \ p6 e2 H
- ;mail.force_extra_parameters =
复制代码 & T" g/ k: J' r" s% [1 _! |! B
注意以上只需要开启sendmail_path即可,然后保存 ' |; j5 R/ L9 f$ `* ~
5 c# K1 _+ C' y# c
接着修改sendmail目录下的sendmail.ini文件,主要填的内容有以下几项 8 A* O) q0 {. k. K
- smtp_server=smtp服务器地址(如 smtp.ym.163.com)
! o& V$ W* r, I - auth_username=邮箱登录名(如 info@xxxx.com) 5 `# t8 i8 u8 X( k, w
- auth_password=邮箱密码(如 xxxxxx) z. ~3 w4 V3 L5 _5 d
- force_sender=发件人地址全写(如 info@xxxx.com)
复制代码 另外还有一项
1 m4 C m0 x4 g+ G' V9 B- ; auto = use SSL for port 465, otherwise try to use TLS
复制代码
) x( H; I5 d; x* S把前面的";"删除,即开启SSL安全登录选项即可
" u2 k2 n( J1 m' i- q/ P; N, m5 E% z2 S$ l2 C" r; l, c. P
以上四项正确填写修改完成后保存,然后重启IIS即可正常使用。 - T* e) k$ z F
9 G L- M! P2 T! g4 t7 s r$ W6 O如果不能发送邮件,检查下端口是不是被屏蔽了,杀毒软件是不是设置了禁止发送邮件等 * f. J" K& Z' g5 j
& r5 Y, L) t2 _" C
|
|