Sendmail, as a free email server software, has been widely used in various servers. It has certain characteristics in terms of stability, portability, and ensuring that there are no bugs, and it can be searched on the network. to a large amount of usage data.
If you find it troublesome to configure the server yourself, you can directly use PHPMailer to call the third-party mail server, which is simple and trouble-free. The git address is as follows:
https://github.com/PHPMailer/PHPMailer
1. Install components
yum install sendmail mailx
2. Modify the configuration file /etc/mail.rc
Add the following parameters:
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. Command line to send mail test
echo "测试邮件" | mail -s '请在明天下午联系我' 111@qq.com
At this time, calling the mail function in the PHP script will return false, open the error log, and display:
May 23 13:09:26 localhost sendmail[3901]: NOQUEUE: SYSERR(php-fpm): /etc/mail/sendmail.cf: line 0: cannot open: Permission denied
Because we have not yet enabled support for httpd to send emails
4. Enable support for httpd to send emails
setsebool -P httpd_can_sendmail 1
5. If a dsn:service unavailable error occurs, it needs to be modified. hostname
hostname <hostname> #假如是本地服务器,尝试设置为本地IP地址
Recommended learning: php video tutorial
The above is the detailed content of In order to use the mailbox service, how to configure sendmail in php7. For more information, please follow other related articles on the PHP Chinese website!