LNMP笔记:解决mail函数不能发送邮件

这两天一直在学习配置阿里云服务器,目前打算使用LNMP环境,在探针里测试发送邮件,失败了。已经确定mail()函数是开启的,于是乎,Google一下,发现 李思章 的方法不错,Mark一下。

问题根源

没有安装或启动 sendmail 组件

解决办法

我是新手,命令不熟,所以写的很详细,老鸟勿喷哦

1.重新安装 sendmail 组件,我用的是 CentOS ,使用下面的命令安装

1
yum install sendmail

2.使用下面的命令重启php-fpm进程

1
/etc/init.d/php-fpm restart

3.检测sendmail是否运行正常

1
/etc/init.d/sendmail status

如果显示正在运行running 就可以。

可能用到的命令

1
2
3
4
5
/etc/init.d/sendmail start (启动sendmail)
 
/etc/init.d/sendmail stop  (关闭sendmail)
 
/etc/init.d/sendmail restart (重启sendmail)

4.配置php.ini,填写sendmail的绝对路径

使用命令打开编辑php.ini

1
vi /usr/local/php/etc/php.ini

输入?sendmail_path 查找定位(或者手动跳转找到sendmail_path),你会发现默认是下面的代码

1
;sendmail_path =

按 i 进入编辑,将这行修改为

1
sendmail_path = /usr/sbin/sendmail -t –i

按 Esc 键退出编辑,输入 :wq 保存退出

5.重启php-fpm进程

1
/etc/init.d/php-fpm restart

 

再次测试,成功了!

转载于:https://www.cnblogs.com/xssxss/archive/2013/03/04/2942569.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值