您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

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

2025/12/13 0:23:30发布25次查看
sendmail作为一种免费的邮件服务器软件,已被广泛的应用于各种服务器中,它在稳定性、可移植性、及确保没有bug等方面具有一定的特色,且可以在网络中搜索到大量的使用资料。
假如嫌自己配置服务器麻烦,直接使用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.comset 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地址
推荐学习:php视频教程
以上就是为了使用邮箱服务,php7该如何配置sendmail的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product