搜索
查看: 18406|回复: 1

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

[复制链接]
发表于 2012-9-2 08:29:24 | 显示全部楼层 |阅读模式
  最近研究uchome,使用在线发邮件的功能,但是测试了"通过 PHP 函数的 sendmail 发送(推荐此方式)"怎么都没用,因为本人现在用的是iis+php环境,怎么调试都没有用,经过研究之后搞定,分享一下教大家在自己服务器上配置sendmail。很多php的网站例如Discuz的论坛和各种phpCMS的网站都用到。
5 \. N3 B7 }6 A0 v) z: _: Z首先你需要先到从http://glob.com.au/sendmail/下载sendmail.zip文件,点此可以直接下载噢,然后把它解压到如D:\php\sendmail\目录下。
( o( t* D5 {- F% S# w1 j然后打开php.ini文件,找到下面这段代码  E5 m& r9 o) ?
  1. [mail function]
    0 `9 c5 P! l2 o% i4 W
  2. ; For Win32 only. 1 A7 S; l2 j9 V  }; {0 D
  3. SMTP = localhost
    : a* k) s# I& V1 i9 |
  4. smtp_port = 25 9 u. k, {2 T$ g; P( U
  5. ; For Win32 only.
    & U6 g: ^5 W3 Z% g* _
  6. ;sendmail_from = me@example.com ( o7 t9 {* c" X+ G6 v1 s* |
  7. ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). + j6 Z& h7 x2 s
  8. ; sendmail_path = ""
    . z/ O$ c: B2 f/ Y- x7 {6 K6 F
  9. ; Force the addition of the specified parameters to be passed as extra parameters   J- a! F+ ~% P( _) M' P
  10. ; to the sendmail binary. These parameters will always replace the value of / c' o! k6 \2 \6 P2 }4 [% c6 a$ B8 F
  11. ; the 5th parameter to mail(), even in safe mode. 2 n- `, p! I, L% }' 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",改完后的即是 6 |( Y: O) X6 G; Y. f8 G9 ]1 X
  1. [mail function]
    # N1 m/ r4 g- ?0 N! R+ e# H
  2. ; For Win32 only. # P% A! a; [. N  Y' |  [
  3. ;SMTP = localhost
    0 I/ X% w( z( `
  4. ;smtp_port = 25 2 y' j' t* l# i4 d6 `# t
  5. ; For Win32 only.
    $ R# `0 u6 k( [& y# b1 ^, ]
  6. ;sendmail_from = me@example.com ; _4 C  u$ o% {9 x; M  f* h
  7. ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). : U. Q& E$ |- i" O& n
  8. sendmail_path = "d:\php\sendmail\sendmail.exe -t"   F2 ]) f: @2 ~; C' h4 a
  9. ; Force the addition of the specified parameters to be passed as extra parameters " L9 D; F# U: Y" W
  10. ; to the sendmail binary. These parameters will always replace the value of 2 h: t# f& c4 e. n# O9 H- \
  11. ; the 5th parameter to mail(), even in safe mode. ( k( R0 m  f  h$ s5 Y- j) h
  12. ;mail.force_extra_parameters =
复制代码

3 y5 f( g  _4 M! D" O+ O注意以上只需要开启sendmail_path即可,然后保存 ! E- i# q  W$ I
& W: _( A0 A+ o1 m' L
接着修改sendmail目录下的sendmail.ini文件,主要填的内容有以下几项 : _( Q$ j' Z. n+ ?5 L
  1. smtp_server=smtp服务器地址(如 smtp.ym.163.com) ) p% S6 N8 S. r# `0 u
  2. auth_username=邮箱登录名(如 info@xxxx.com)
      Q! ]8 ?6 U; S$ Z+ {
  3. auth_password=邮箱密码(如 xxxxxx)
    0 K# H4 k% D. B0 }- u  N3 W; Z
  4. force_sender=发件人地址全写(如 info@xxxx.com)
复制代码
另外还有一项 4 r# L7 f, e) k3 c2 g9 R
  1. ; auto = use SSL for port 465, otherwise try to use TLS
复制代码
( W8 [0 Q! O% S( c: E7 K+ _
把前面的";"删除,即开启SSL安全登录选项即可
7 c3 T$ b9 F* t% _$ w6 W9 w- y
2 n5 Y! m! V4 W! @以上四项正确填写修改完成后保存,然后重启IIS即可正常使用。
- U) H* \- }- V
/ n" r- F% I& v9 s. |( Y( Y如果不能发送邮件,检查下端口是不是被屏蔽了,杀毒软件是不是设置了禁止发送邮件等  
, }6 @& Y" q9 l& I! X
8 L# z8 C# [' o! q& i
回复

使用道具 举报

 楼主| 发表于 2012-9-2 10:24:28 | 显示全部楼层
http://www.phpmarker.com/1.html 4 p4 C* |8 B2 y, T# \7 A" G; \
这个是另外一种方法,但是两种方法测试过,貌似都不管用
您需要登录后才可以回帖 登录 | 注册帐号

本版积分规则

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

虾皮社区,成立十年了!

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

Copyright © 2007-2019 xp6.org Powered by Discuz

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