Windows下wamp sever+sendmail使用mail()函数时的配置

我在自己的Windows 7系统下安装了wampserver服务器,但是使用mail()函数发送邮件时却报错了,于是在网上看了mail()函数的手册和相关信息,发现可以使用很多方法实现php脚本发送邮件,暂时记录一个比较简单的:

1,下载sendmail.zip 地址:http://glob.com.au/sendmail/;

2,解压缩sendmail.zip到sendmail文件夹,并将该文件夹移动到c:\wamp\下;

3,打开php.ini,可先打开wamp,点击其图标php->php.ini找到该文件,打开即可,在里面搜索到

describe1:

[mail function]

; For Win32 only.

; http://php.net/smtp

;SMTP = localhost

; http://php.net/smtp-port

;smtp_port = 25


; For Win32 only.

; http://php.net/sendmail-from

;sendmail_from = you@yourdomain

ps:请注意上面这些内容全部需要用;号注释掉!


describe2:

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").

; http://php.net/sendmail-path

sendmail_path ="C:\wamp\sendmail\sendmail.exe -t"

ps:上面这行填写的是sendmail的路径,将其告知php解析器


describe3:

; Force the addition of the specified parameters to be passed as extra parameters

; to the sendmail binary. These parameters will always replace the value of

; the 5th parameter to mail(), even in safe mode.

;mail.force_extra_parameters =


; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename

mail.add_x_header = On


; Log all mail() calls including the full path of the script, line #, to address and headers

;mail.log =

ps:以上(除了“mail.add_x_header = On”外),其余的也都要用;注释掉的!

4,在c:\wamp\sendmail\目录下找到sendmail.ini这个文件并打开,如下几个地方一定要修改,其他默认的地方不变即可:

smtp_server=SMTP服务器(例如smtp.qq.com或者smtp.163.com)

auto = use SSL for port 465, otherwise try to use TLS(去掉他前面本来有的 ; 号,表示启用SSL)

default_domain=mydomain.com变成 ;default_domain=mydomain.com(这个很重要,这个不弄的话,php不会报错,但是邮件确实发不出去!!!我尝试很久才知道)

auth_username=您的邮件服务器用户名(比如XX@qq.com,注意进入相关(如qq)邮箱开启SMTP服务)

auth_password=您的邮件服务器用户(授权)密码

force_sender=您的邮件服务器用户名(同auth_username)

 
 

这些全部做完后,您在自己本地写好php后使用wampsever服务器和sendmail服务器就可以成功地使用mail()函数发送邮件,这在论坛设计时候的评论,反馈等方面很有用。

原文:点击打开链接

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值