using Postfix to get php's mail function to take effect

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.