Home > Backend Development > PHP7 > In order to use the mailbox service, how to configure sendmail in php7

In order to use the mailbox service, how to configure sendmail in php7

醉折花枝作酒筹
Release: 2023-02-18 07:50:02
forward
2311 people have browsed it

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.

In order to use the mailbox service, how to configure sendmail in php7

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
Copy after login

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
Copy after login

3. Command line to send mail test

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

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
Copy after login

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
Copy after login

5. If a dsn:service unavailable error occurs, it needs to be modified. hostname

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

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template