Enable the php mail () function in Ubuntu and solve the problem of slow email sending speed.
If you need to use the mail () function of php to send emails, you need to install the sendmail component on the server. This is also introduced in the mail () function section of the php manual. Then
Install the sendmail command in Ubuntu:
Copy codeThe Code is as follows:
Sudo apt-get install sendmail
After installation, start the sendmail service:
Copy codeThe Code is as follows:
Sudo service sendmail start
With sendmail support, you can use the mail () function in php to send emails.
The reason for the slow speed of mail () sending in php is that DNS resolution is slow, and it is often because the hostname of the server is not a real domain name that can be resolved.
Copy codeThe Code is as follows:
Sudo vim/etc/hosts
Then press the I key to modify the code. Add localhost. localdomain and your host alias in section 127.0.0.1. After the modification, Press Esc to exit the editing state, and then enter ': wq' to save and exit.
Finally, restart the sendmail service:
Copy codeThe Code is as follows:
Sudo service sendmail restart
The above is all the content of this article. I hope you will like it.
Please take a moment to share your article with your friends or leave a comment. Thank you for your support!