搜索
查看: 18877|回复: 1

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

[复制链接]
发表于 2012-9-2 08:29:24 | 显示全部楼层 |阅读模式
  最近研究uchome,使用在线发邮件的功能,但是测试了"通过 PHP 函数的 sendmail 发送(推荐此方式)"怎么都没用,因为本人现在用的是iis+php环境,怎么调试都没有用,经过研究之后搞定,分享一下教大家在自己服务器上配置sendmail。很多php的网站例如Discuz的论坛和各种phpCMS的网站都用到。
6 c" \9 F) }0 J0 p# j  O首先你需要先到从http://glob.com.au/sendmail/下载sendmail.zip文件,点此可以直接下载噢,然后把它解压到如D:\php\sendmail\目录下。$ S  G& r, F) r% u# \: G3 u
然后打开php.ini文件,找到下面这段代码1 {! G* o, x$ a; C$ H
  1. [mail function] & N0 D6 c" r2 o+ Q
  2. ; For Win32 only.
    ) x7 ~6 X) t! y1 @
  3. SMTP = localhost
    * J+ V+ l9 _& k. S9 N
  4. smtp_port = 25
    : d, u  q7 I3 S; r; ^9 }& D
  5. ; For Win32 only.
    / s- k1 C; K4 G2 e; t3 s
  6. ;sendmail_from = me@example.com ; s6 n9 p) j4 s* `( Y3 |
  7. ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ! R6 a; j, \% Z9 j6 d. u# x3 t
  8. ; sendmail_path = "" & J. h5 g' j) N8 ?5 r/ G6 l4 r/ ?
  9. ; Force the addition of the specified parameters to be passed as extra parameters
    + W- `5 ^+ G! p
  10. ; to the sendmail binary. These parameters will always replace the value of
      y" A( b2 _9 Y/ n! `) \
  11. ; the 5th parameter to mail(), even in safe mode. 6 _. ^# @% w5 ]5 M
  12. ;mail.force_extra_parameters =
复制代码
默认情况下是以本机做为邮件服务器,这里我们需要借用sendmail来发送邮件,用sendmail来配置如用qq、163的邮箱来发送(一般都是以这种方式)所以我们需要把所有的选项都注销,即把SMTP = localhost和smtp_port = 25前面加上";"然后把sendmai_path=""前面的";"删掉,改为sendmai_path="d:\php\sendmail\sendmail.exe -t",改完后的即是
  {# ~  {( p  Q/ O, X/ I/ Q
  1. [mail function] 8 u$ ]/ _8 W; {* R0 c" `1 ^
  2. ; For Win32 only. 9 b3 ]5 d  Q  X8 r
  3. ;SMTP = localhost , E3 O- f& ~6 A2 J# [6 ]
  4. ;smtp_port = 25 % Y- G- n  t7 A
  5. ; For Win32 only.
    + y; F8 a. n  {5 v' T
  6. ;sendmail_from = me@example.com   ^% y6 Y8 C$ r4 V* i
  7. ; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
    / \/ k5 s! |  x% N# S% s8 G
  8. sendmail_path = "d:\php\sendmail\sendmail.exe -t" ; e% o+ E9 }) {6 e! B
  9. ; Force the addition of the specified parameters to be passed as extra parameters 3 j1 c( E2 r+ O6 S% b
  10. ; to the sendmail binary. These parameters will always replace the value of 6 }  N3 k! s" P2 v
  11. ; the 5th parameter to mail(), even in safe mode. ' f$ V. ?5 C7 ~+ K
  12. ;mail.force_extra_parameters =
复制代码
1 p" Q0 S" s% |% A* W2 s
注意以上只需要开启sendmail_path即可,然后保存
0 H  ?, ^( o' q% F& D( C9 y/ \$ X1 X+ b. N& ~$ i$ s1 s3 E1 n
接着修改sendmail目录下的sendmail.ini文件,主要填的内容有以下几项
; {0 e* h  {: F6 A, L% a
  1. smtp_server=smtp服务器地址(如 smtp.ym.163.com) , f; A! @" E7 W6 g( O" l
  2. auth_username=邮箱登录名(如 info@xxxx.com)
    1 J/ g4 m- `, `
  3. auth_password=邮箱密码(如 xxxxxx)
    $ C& a' i/ R0 z" z0 G
  4. force_sender=发件人地址全写(如 info@xxxx.com)
复制代码
另外还有一项 : n6 u% Q" X7 r
  1. ; auto = use SSL for port 465, otherwise try to use TLS
复制代码

. s2 S6 O! f5 G7 a0 ^把前面的";"删除,即开启SSL安全登录选项即可
! ]) S: M7 X1 o9 E, N9 e9 x0 K8 x, R
- p7 J( q7 D4 G$ N0 h以上四项正确填写修改完成后保存,然后重启IIS即可正常使用。 4 U9 h+ ~! m+ X3 Q7 \  G; w

/ [* {5 V3 F' D" l8 U  ]. L/ m/ F8 j如果不能发送邮件,检查下端口是不是被屏蔽了,杀毒软件是不是设置了禁止发送邮件等  2 g7 F) J+ [( }3 ]& v

0 s5 Y9 ^- }' V
回复

使用道具 举报

 楼主| 发表于 2012-9-2 10:24:28 | 显示全部楼层
http://www.phpmarker.com/1.html   e* g7 F2 k& U( i, l3 D
这个是另外一种方法,但是两种方法测试过,貌似都不管用
您需要登录后才可以回帖 登录 | 注册帐号

本版积分规则

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

虾皮社区,成立十年了!

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

Copyright © 2007-2019 xp6.org Powered by Discuz

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