搜索
查看: 18790|回复: 1

[网站] iis下php 通过 PHP 函数的 sendmail 发送的配置方法

[复制链接]
发表于 2012-9-2 08:29:24 | 显示全部楼层 |阅读模式
  最近研究uchome,使用在线发邮件的功能,但是测试了"通过 PHP 函数的 sendmail 发送(推荐此方式)"怎么都没用,因为本人现在用的是iis+php环境,怎么调试都没有用,经过研究之后搞定,分享一下教大家在自己服务器上配置sendmail。很多php的网站例如Discuz的论坛和各种phpCMS的网站都用到。0 \* ~/ {6 L" k. G+ L4 G2 v
首先你需要先到从http://glob.com.au/sendmail/下载sendmail.zip文件,点此可以直接下载噢,然后把它解压到如D:\php\sendmail\目录下。+ Y7 a+ x) H- K7 T7 c) C
然后打开php.ini文件,找到下面这段代码
  C2 l) ?6 J3 q; n7 G8 |
  1. [mail function] 1 P+ W3 Y! n0 C+ G  z
  2. ; For Win32 only.
    # G! x# o- X: x
  3. SMTP = localhost ; e) @# j! t5 Z( }% c0 L" u
  4. smtp_port = 25 5 |9 e/ ?/ {: @5 v: X
  5. ; For Win32 only.
    6 n# f& o% ?) f: r/ k# e' V
  6. ;sendmail_from = me@example.com ! C8 P- X% ^+ ~  |/ M2 b
  7. ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). : Z- a9 e+ E& r7 _6 J
  8. ; sendmail_path = "" ( Z) J! [% O6 A- ?
  9. ; Force the addition of the specified parameters to be passed as extra parameters
    ( M& C0 ~) p7 X3 S
  10. ; to the sendmail binary. These parameters will always replace the value of
    , F" x$ \' G! s" v7 [" [4 W
  11. ; the 5th parameter to mail(), even in safe mode. ) H: p- m) T. x& u/ q
  12. ;mail.force_extra_parameters =
复制代码
默认情况下是以本机做为邮件服务器,这里我们需要借用sendmail来发送邮件,用sendmail来配置如用qq、163的邮箱来发送(一般都是以这种方式)所以我们需要把所有的选项都注销,即把SMTP = localhost和smtp_port = 25前面加上";"然后把sendmai_path=""前面的";"删掉,改为sendmai_path="d:\php\sendmail\sendmail.exe -t",改完后的即是
# y2 t! @' h9 r4 q: Z- o) ^( a4 M
  1. [mail function]
    ( v; e! y; ?- e. l, b: A+ {2 M
  2. ; For Win32 only. # y9 O' W6 d6 p! ?
  3. ;SMTP = localhost + k! P5 U% b" |" t. J. t/ L& v
  4. ;smtp_port = 25
    " e# d" Y* z8 n3 B7 ]+ j
  5. ; For Win32 only.
    ( B) q& u. h7 j4 k; ~7 L0 J
  6. ;sendmail_from = me@example.com 4 x; S3 h' U3 \$ C, r+ A
  7. ; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
    ( A' b3 [1 e+ _$ a! L! L( n
  8. sendmail_path = "d:\php\sendmail\sendmail.exe -t"   V! {% w0 A5 E
  9. ; Force the addition of the specified parameters to be passed as extra parameters 8 ^/ t, |! X4 R. m0 [5 n  T
  10. ; to the sendmail binary. These parameters will always replace the value of
    + f) I) _# |; T) v; `$ Q; f
  11. ; the 5th parameter to mail(), even in safe mode. 1 T/ O8 y9 d# x" X1 U- L
  12. ;mail.force_extra_parameters =
复制代码

& Y2 U( x0 i' \% u1 ~注意以上只需要开启sendmail_path即可,然后保存 ( E  K1 Z; N9 ^; I/ d+ C) E1 \
+ M8 Y1 n2 W# z( \7 }
接着修改sendmail目录下的sendmail.ini文件,主要填的内容有以下几项
  h. h6 k% _2 Z# X
  1. smtp_server=smtp服务器地址(如 smtp.ym.163.com) 9 N0 f: n3 L. t- I8 H2 t% _
  2. auth_username=邮箱登录名(如 info@xxxx.com) 6 T3 A7 A2 C& ^% Q
  3. auth_password=邮箱密码(如 xxxxxx)
    . v8 G( H( e* `! k1 d
  4. force_sender=发件人地址全写(如 info@xxxx.com)
复制代码
另外还有一项
9 R3 i0 T) [; Q! f% }
  1. ; auto = use SSL for port 465, otherwise try to use TLS
复制代码

0 C+ Q% E; x4 `4 i% z+ A9 d3 y把前面的";"删除,即开启SSL安全登录选项即可 8 d$ S# A8 R1 K" K8 _

( f# d4 [9 I4 o2 {. R以上四项正确填写修改完成后保存,然后重启IIS即可正常使用。 " A% i! X7 H: _- P

! \4 `. n- h, J* w( Z' u, s$ i如果不能发送邮件,检查下端口是不是被屏蔽了,杀毒软件是不是设置了禁止发送邮件等  / K; m% l; ], Q3 f

/ H! L+ }& `( B# p* s$ |  F  j
回复

使用道具 举报

 楼主| 发表于 2012-9-2 10:24:28 | 显示全部楼层
http://www.phpmarker.com/1.html , r/ p3 s* O- U$ {5 X' y9 e4 Q
这个是另外一种方法,但是两种方法测试过,貌似都不管用
您需要登录后才可以回帖 登录 | 注册帐号

本版积分规则

热议作品
精华帖子排行
精彩推荐

虾皮社区,成立十年了!

站长自己也搞不懂想做个什么,反正就是一直在努力的做!

Copyright © 2007-2019 xp6.org Powered by Discuz

QQ|Archiver|手机版|小黑屋|虾皮社区 鲁公网安备 37021102000261号 |网站地图
返回顶部 返回列表