搜索
查看: 18530|回复: 1

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

[复制链接]
发表于 2012-9-2 08:29:24 | 显示全部楼层 |阅读模式
  最近研究uchome,使用在线发邮件的功能,但是测试了"通过 PHP 函数的 sendmail 发送(推荐此方式)"怎么都没用,因为本人现在用的是iis+php环境,怎么调试都没有用,经过研究之后搞定,分享一下教大家在自己服务器上配置sendmail。很多php的网站例如Discuz的论坛和各种phpCMS的网站都用到。! {/ i+ Z& q9 z* R: Z, x1 R* i; ?* [
首先你需要先到从http://glob.com.au/sendmail/下载sendmail.zip文件,点此可以直接下载噢,然后把它解压到如D:\php\sendmail\目录下。
& d( d; H7 ]5 m* p: T0 ?1 ~然后打开php.ini文件,找到下面这段代码7 W, C' G$ T8 a8 U& w1 X6 ~% d
  1. [mail function] . T4 W, c. P" n9 w8 ]* C; z
  2. ; For Win32 only. , J+ R( s: x1 s- t* b
  3. SMTP = localhost
    - t0 k1 T) u3 n( {7 U' O5 d3 X0 K
  4. smtp_port = 25 * @  c7 M& }% H+ G+ p5 K8 j% l
  5. ; For Win32 only. : X! Y1 W1 f% F& S% D0 L$ i( Q; z
  6. ;sendmail_from = me@example.com ( R! C; S- Q' F
  7. ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). 9 q, d' _: ~7 @/ ?; k
  8. ; sendmail_path = "" * M: v8 a6 O6 U! v: c. W9 A* M
  9. ; Force the addition of the specified parameters to be passed as extra parameters ) D3 }( R! B9 Q, K: }2 N
  10. ; to the sendmail binary. These parameters will always replace the value of
    - D% s8 M3 y- m& Z- i6 b" l
  11. ; the 5th parameter to mail(), even in safe mode. , n* @- p) p2 z6 q& v$ O
  12. ;mail.force_extra_parameters =
复制代码
默认情况下是以本机做为邮件服务器,这里我们需要借用sendmail来发送邮件,用sendmail来配置如用qq、163的邮箱来发送(一般都是以这种方式)所以我们需要把所有的选项都注销,即把SMTP = localhost和smtp_port = 25前面加上";"然后把sendmai_path=""前面的";"删掉,改为sendmai_path="d:\php\sendmail\sendmail.exe -t",改完后的即是 ( P3 u5 Z, I$ R/ L
  1. [mail function]
    / n7 A( B% ^5 o/ }
  2. ; For Win32 only.
    / t/ \* _- `, B) V
  3. ;SMTP = localhost % J4 g8 u5 g. }! X6 O
  4. ;smtp_port = 25 1 y. y! X) y/ ^
  5. ; For Win32 only.
    9 |; O% i7 ], T- t! X/ L
  6. ;sendmail_from = me@example.com . j- z  B: n+ |+ b5 D) x
  7. ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). 3 V. K) W" ]% h8 R" i
  8. sendmail_path = "d:\php\sendmail\sendmail.exe -t"   u9 z; J. J0 D
  9. ; Force the addition of the specified parameters to be passed as extra parameters , s4 @, U' B5 R
  10. ; to the sendmail binary. These parameters will always replace the value of
    ! f4 L: E; M$ J( c0 z1 ]  M4 @. i
  11. ; the 5th parameter to mail(), even in safe mode.   b2 m5 Y9 q: V4 M
  12. ;mail.force_extra_parameters =
复制代码

, F0 ~5 n/ c; g: O' q; ?注意以上只需要开启sendmail_path即可,然后保存
+ }. q0 S5 a; N3 Q/ T0 A* o: v" Y$ r; n  X* b; ?/ ?
接着修改sendmail目录下的sendmail.ini文件,主要填的内容有以下几项 2 u6 {. e) ?+ H6 Y8 f
  1. smtp_server=smtp服务器地址(如 smtp.ym.163.com) 7 i: ~# `. W, G2 E+ \4 l) q- M$ d- C7 B+ G
  2. auth_username=邮箱登录名(如 info@xxxx.com)
    2 Q  c4 Y2 s+ q" t* ^
  3. auth_password=邮箱密码(如 xxxxxx) 8 s: H1 }+ i/ g% i0 u
  4. force_sender=发件人地址全写(如 info@xxxx.com)
复制代码
另外还有一项 / L- \  M+ y% H
  1. ; auto = use SSL for port 465, otherwise try to use TLS
复制代码

6 Q( A, Y+ }* q; F, y把前面的";"删除,即开启SSL安全登录选项即可
; ?8 F+ W7 ]3 a& L% M' I  H2 Y$ u9 |  i8 N! t
以上四项正确填写修改完成后保存,然后重启IIS即可正常使用。
2 P0 Z$ q' x+ |, `- K
! K2 U* e1 S! _0 j如果不能发送邮件,检查下端口是不是被屏蔽了,杀毒软件是不是设置了禁止发送邮件等  
- @3 L6 @5 ]) D, A$ Q
5 @/ _2 @) t! _  r6 Q. p! i9 R( v  S
回复

使用道具 举报

 楼主| 发表于 2012-9-2 10:24:28 | 显示全部楼层
http://www.phpmarker.com/1.html
' ]( I" C1 z2 P% L这个是另外一种方法,但是两种方法测试过,貌似都不管用
您需要登录后才可以回帖 登录 | 注册帐号

本版积分规则

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

虾皮社区,成立十年了!

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

Copyright © 2007-2019 xp6.org Powered by Discuz

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