If you need to use PHP's mail() function to send emails, you need to The server must install the sendmail component to support this. This is also introduced in the mail() function section of the PHP manual. Then in
Command to install sendmail under Ubuntu:
Copy code The code is as follows:
sudo apt-get install sendmail
After installation, start the sendmail service:
Copy code The code is as follows:
sudo service sendmail start
With the support of sendmail, you can use the mail() function to send emails in php.
Generally, the reason why sending emails using mail() in PHP is slow is due to slow DNS resolution, and it is often because the hostname of the server is not a real resolvable domain name.
Copy code The code is as follows:
sudo vim /etc/hosts
Then press the i key, and then you can modify the code. Add localhost.localdomain and your host alias in the 127.0.0.1 section. After making the changes, press the Esc key to exit the editing state, then enter ‘:wq’ to save and exit.
Finally restart the sendmail service:
Copy code The code is as follows:
sudo service sendmail restart
The above is the entire content of this article, I hope you all like it.
Please take a moment to share the article with your friends or leave a comment. We will sincerely thank you for your support!