iis下php mail函数的sendmail配置方法(官方推荐)


Posted in PHP onApril 25, 2012

首先你需要先到从http://glob.com.au/sendmail/下载sendmail.zip文件,点此可以直接下载噢,然后把它解压到如D:\php\sendmail\目录下。

然后打开php.ini文件,找到下面这段代码

[mail function] 
; For Win32 only. 
SMTP = localhost 
smtp_port = 25 
; For Win32 only. 
;sendmail_from = me@example.com 
; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). 
; sendmail_path = "" 
; 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 =

默认情况下是以本机做为邮件服务器,这里我们需要借用sendmail来发送邮件,用sendmail来配置如用qq、163的邮箱来发送(一般都是以这种方式)所以我们需要把所有的选项都注销,即把SMTP = localhost和smtp_port = 25前面加上";"然后把sendmai_path=""前面的";"删掉,改为sendmai_path="d:\php\sendmail\sendmail.exe -t",改完后的即是
[mail function] 
; For Win32 only. 
;SMTP = localhost 
;smtp_port = 25 
; For Win32 only. 
;sendmail_from = me@example.com 
; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). 
sendmail_path = "d:\php\sendmail\sendmail.exe -t" 
; 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 =

注意以上只需要开启sendmail_path即可,然后保存

接着修改sendmail目录下的sendmail.ini文件,主要填的内容有以下几项

smtp_server=smtp服务器地址(如 smtp.ym.163.com) 
auth_username=邮箱登录名(如 info@xxxx.com) 
auth_password=邮箱密码(如 xxxxxx) 
force_sender=发件人地址全写(如 info@xxxx.com)

另外还有一项
; auto = use SSL for port 465, otherwise try to use TLS

把前面的";"删除,即开启SSL安全登录选项即可

以上四项正确填写修改完成后保存,然后重启IIS即可正常使用。

如果不能发送邮件,检查下端口是不是被屏蔽了,mcafee是不是设置了禁止发送邮件等

PHP 相关文章推荐
用PHP实现递归循环每一个目录
Aug 08 PHP
字母顺序颠倒而单词顺序不变的php代码
Aug 08 PHP
PHP操作XML作为数据库的类
Dec 19 PHP
php文件上传表单摘自drupal的代码
Feb 15 PHP
php Rename 更改文件、文件夹名称
May 24 PHP
PHP数组的交集array_intersect(),array_intersect_assoc(),array_inter_key()函数的小问题
May 29 PHP
PHP中header和session_start前不能有输出原因分析
Jan 11 PHP
PHP实现的简单缓存类
Jul 29 PHP
PHP批量去除BOM头内容信息代码
Mar 11 PHP
php微信公众账号开发之前五个坑(一)
Sep 18 PHP
PHP操作Postgresql封装类与应用完整实例
Apr 24 PHP
实例讲解通过​PHP创建数据库
Jan 20 PHP
php判断变量类型常用方法
Apr 24 #PHP
介绍一些PHP判断变量的函数
Apr 24 #PHP
PHP的几个常用数字判断函数代码
Apr 24 #PHP
php中邮箱地址正则表达式实现与详解
Apr 24 #PHP
PHPMYADMIN导入数据最大为2M的解决方法
Apr 23 #PHP
php 多关键字 高亮显示实现代码
Apr 23 #PHP
php入门之连接mysql数据库的一个类
Apr 21 #PHP
You might like
php无限级分类实现方法分析
2016/10/19 PHP
PhpStorm的使用教程(本地运行PHP+远程开发+快捷键)
2020/03/26 PHP
js获取变量
2006/08/24 Javascript
javascript for循环从入门到偏门(效率优化+奇特用法)
2012/08/01 Javascript
js实现日期级联效果
2014/01/23 Javascript
jQuery之ajax删除详解
2014/02/27 Javascript
Jquery实现侧边栏跟随滚动条固定(兼容IE6)
2014/04/02 Javascript
js阻止事件追加的具体实现
2014/10/15 Javascript
利用jQuery及AJAX技术定时更新GridView的某一列数据
2015/12/04 Javascript
JavaScript对象数组排序函数及六个用法
2015/12/23 Javascript
微信小程序实现顶部选项卡(swiper)
2020/06/19 Javascript
深入浅析JSONAPI在PHP中的应用
2017/12/24 Javascript
vue 动态修改a标签的样式的方法
2018/01/18 Javascript
详解Vue内部怎样处理props选项的多种写法
2018/11/06 Javascript
js布局实现单选按钮控件
2020/01/17 Javascript
JavaScript实现鼠标移入随机变换颜色
2020/11/24 Javascript
进一步理解Python中的函数编程
2015/04/13 Python
在Python的Django框架上部署ORM库的教程
2015/04/20 Python
python用Pygal如何生成漂亮的SVG图像详解
2017/02/10 Python
python 表达式和语句及for、while循环练习实例
2017/07/07 Python
Python多图片合并PDF的方法
2019/01/03 Python
解决python tkinter界面卡死的问题
2019/07/17 Python
Python selenium 自动化脚本打包成一个exe文件(推荐)
2020/01/14 Python
PyQT5 实现快捷键复制表格数据的方法示例
2020/06/19 Python
德购商城:德国进口直邮商城
2017/06/13 全球购物
台湾团购、宅配和优惠券:17Life
2017/08/14 全球购物
远程教育心得体会
2014/01/03 职场文书
入党自荐书范文
2014/03/09 职场文书
消防安全责任书
2014/04/14 职场文书
致地震灾区的慰问信
2015/03/23 职场文书
2015年仓库管理员工作总结
2015/04/21 职场文书
国庆节主题班会
2015/08/15 职场文书
护理培训心得体会
2016/01/22 职场文书
pytorch 如何使用float64训练
2021/05/24 Python
mysql sum(if())和count(if())的用法说明
2022/01/18 MySQL
Spring JPA 增加字段执行异常问题及解决
2022/06/10 Java/Android