为了使用邮箱服务,php7该如何配置sendmail

 2611

为了使用邮箱服务,php7该如何配置sendmail


假如嫌自己配置服务器麻烦,直接使用PHPMailer调用第三方邮件服务器,简单省事。git地址如下:

https://github.com/PHPMailer/PHPMailer


1、安装组件

yum install sendmail mailx

2、修改配置文件/etc/mail.rc

添加下列参数:

set from=acc@163.com  #发送方
set smtp=smtp.163.com
set smtp-auth-user=acc@163.com #账号
set smtp-auth-password=password #授权码
set smtp-auth=login

3、命令行发送邮件测试

echo "测试邮件" | mail -s '请在明天下午联系我' 111@qq.com

此时在PHP脚本中调用mail函数,会返回false,打开错误日志,显示:

May 23 13:09:26 localhost sendmail[3901]: NOQUEUE: SYSERR(php-fpm): /etc/mail/sendmail.cf: line 0: cannot open: Permission denied

因为我们还没开启对于httpd发送邮件的支持

4、开启httpd发送邮件支持

setsebool -P httpd_can_sendmail 1

5、假如出现dsn:service unavailable错误,需要修改hostname

hostname <hostname> #假如是本地服务器,尝试设置为本地IP地址


TAG标签:
本文网址:https://www.zztuku.com/detail-9063.html
站长图库 - 为了使用邮箱服务,php7该如何配置sendmail
申明:如有侵犯,请 联系我们 删除。

评论(0)条

您还没有登录,请 登录 后发表评论!

提示:请勿发布广告垃圾评论,否则封号处理!!

    编辑推荐

    公司员工激励方案PPT模板