Take Ubuntu as an example
Modify PHP.ini, if it is php-fpm, need to modify 2 php.ini files
Sendmail_from = "[email protected]"//email sent to the mailbox, must and from the corresponding Sendmail_path = "Sendmail-t-i-f [email protected]"
Install or reconfigure Postfix
sudo apt-get install postfix//If it is already installed, reconfigure//sudo dpkg-reconfigure postfix
All the way with the default bar, the first can be used to send mail domain name, back as far as possible, or with the default value, I stuck in this place for a long time
Add the server address and the account password for sending email
sudo vim/etc/postfix/sasl_passwd[smtp.123.com] [email protected]: password
After saving
sudo postmap/etc/postfix/sasl_passwdsudo postfix Reload
Edit/ETC/POSTFIX/MAIN.CF, add
Relayhost = [smtp.123.com]//This place will be the same as before # enable SASL authentication smtpd_sasl_auth_enable = yessmtp_sasl_auth_enable = y es# Disallow methods that allow anonymous authentication. Smtp_sasl_security_options = noanonymous# where to find sasl_passwdsmtp_sasl_password_maps = Hash:/etc/postfix/sasl_ passwd
New PHP file for testing
Mail (' [email protected] ', ' My Subject ', ' fuck '); Send yourself
See if you receive the message, if you encounter problems, see the/var/log/mail.log file, focus on whether to the recipient is correct, relay is [Smtp.123.com],from sender is correct
Use Postfix to make PHP's mail function effective