搜索
查看: 18495|回复: 1

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

[复制链接]
发表于 2012-9-2 08:29:24 | 显示全部楼层 |阅读模式
  最近研究uchome,使用在线发邮件的功能,但是测试了"通过 PHP 函数的 sendmail 发送(推荐此方式)"怎么都没用,因为本人现在用的是iis+php环境,怎么调试都没有用,经过研究之后搞定,分享一下教大家在自己服务器上配置sendmail。很多php的网站例如Discuz的论坛和各种phpCMS的网站都用到。0 d5 g, E4 t! }4 }- g- L
首先你需要先到从http://glob.com.au/sendmail/下载sendmail.zip文件,点此可以直接下载噢,然后把它解压到如D:\php\sendmail\目录下。
( [# F4 u! U# @: Z然后打开php.ini文件,找到下面这段代码8 x- t. p$ A0 u2 E! H, F& \6 a& S
  1. [mail function] ' k& {  l$ n: Y
  2. ; For Win32 only.
    . Y2 ^" x- \/ S3 M
  3. SMTP = localhost $ b. n& U2 N0 o0 C9 J; ^
  4. smtp_port = 25 1 ]( Y; d  [5 Y; a& C
  5. ; For Win32 only. 2 p, F/ v$ @% t' j+ g) d
  6. ;sendmail_from = me@example.com + w8 m8 Q9 o, b, R/ N5 D
  7. ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). " w) o( \; @+ t8 B+ Y
  8. ; sendmail_path = ""
    , n( {; n% d2 c* [4 ^
  9. ; Force the addition of the specified parameters to be passed as extra parameters
    ( j+ E8 p. q, u1 z6 v
  10. ; to the sendmail binary. These parameters will always replace the value of
    : U" o. o, R9 R# O8 I9 K
  11. ; the 5th parameter to mail(), even in safe mode.
    ! b5 m; s8 [$ R8 W1 g/ ]; P' x! ~
  12. ;mail.force_extra_parameters =
复制代码
默认情况下是以本机做为邮件服务器,这里我们需要借用sendmail来发送邮件,用sendmail来配置如用qq、163的邮箱来发送(一般都是以这种方式)所以我们需要把所有的选项都注销,即把SMTP = localhost和smtp_port = 25前面加上";"然后把sendmai_path=""前面的";"删掉,改为sendmai_path="d:\php\sendmail\sendmail.exe -t",改完后的即是 ! c& f- K% P* |* L5 t
  1. [mail function] % Y2 d8 x1 M4 W
  2. ; For Win32 only.
    ' q. ^% b4 j: D! Y
  3. ;SMTP = localhost 0 D, j( L( A8 y# v/ H
  4. ;smtp_port = 25
    / E& l- i* P4 k$ C- }6 \. `
  5. ; For Win32 only.
    % P" I2 C% v7 z9 |4 ~1 b2 x8 W6 A
  6. ;sendmail_from = me@example.com
      i3 }! u" }' M4 A6 i: c
  7. ; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
    , A: B0 I+ `" t5 y- m8 @
  8. sendmail_path = "d:\php\sendmail\sendmail.exe -t" - \$ e' N/ E8 _# ?; [& N
  9. ; Force the addition of the specified parameters to be passed as extra parameters
    / I9 d, e/ M+ I, w
  10. ; to the sendmail binary. These parameters will always replace the value of
    2 f2 `8 _+ Y) @* \, U
  11. ; the 5th parameter to mail(), even in safe mode.
    ' W4 P  h8 Q  E
  12. ;mail.force_extra_parameters =
复制代码

: V; r, Z- Y5 F/ h注意以上只需要开启sendmail_path即可,然后保存
3 ~! s7 j+ r. v2 K- y# L& ?( L- k+ r4 Q
: v0 v' t: G/ A* m" D# ~接着修改sendmail目录下的sendmail.ini文件,主要填的内容有以下几项 , j0 k1 B# q( n
  1. smtp_server=smtp服务器地址(如 smtp.ym.163.com)
    + I# x- n$ U% U# `! a' [
  2. auth_username=邮箱登录名(如 info@xxxx.com) 1 M: o" `5 {; R( z' ?1 n) U/ ]6 A
  3. auth_password=邮箱密码(如 xxxxxx) 4 o& B4 O# b. q( A$ o
  4. force_sender=发件人地址全写(如 info@xxxx.com)
复制代码
另外还有一项
  r6 F( B: f4 B
  1. ; auto = use SSL for port 465, otherwise try to use TLS
复制代码
4 H( M/ B: M6 x5 J2 W% @
把前面的";"删除,即开启SSL安全登录选项即可 ( J  q% H& Y9 i3 p6 w1 B: D3 w: i

# d1 t5 I1 l4 G8 ?以上四项正确填写修改完成后保存,然后重启IIS即可正常使用。
" ~" ]6 N$ P. |, D: R$ J, a+ Z6 V1 L  G* o
如果不能发送邮件,检查下端口是不是被屏蔽了,杀毒软件是不是设置了禁止发送邮件等  # S7 \: t: N9 Y% I- E4 `) g7 R7 S

3 w4 g; s& z; Z  x$ Q' v
回复

使用道具 举报

 楼主| 发表于 2012-9-2 10:24:28 | 显示全部楼层
http://www.phpmarker.com/1.html
. a2 |. n1 G1 B" u8 o$ r: g这个是另外一种方法,但是两种方法测试过,貌似都不管用
您需要登录后才可以回帖 登录 | 注册帐号

本版积分规则

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

虾皮社区,成立十年了!

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

Copyright © 2007-2019 xp6.org Powered by Discuz

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