Solve the problem that the mail function in CentOS cannot send emails

Source: Internet
Author: User

This problem is that in the compiled LNMP environment, the WordPress WP Tread Comment plug-in's automatic email reply function is invalid !! Then I installed a PHP probe to test whether the mail function exists, but the mail cannot be sent out.

It's strange that I didn't see such a problem in my independent server and VPS compiling LNMP environment before, and the monk was confused for a while.

After I calmed down, I tried to compare the PHP configuration files that can send emails with those that cannot be sent. The answer is the same, that is, the emails cannot be sent due to no setup problems. Try to use the Shell command mail in Linux to send an email. The new VPS prompts that this command does not exist !!

After further checks, we find that the VPS does not have the basic mail component installed in sendmail Linux by default. It seems that the problem is here !! After re-installing sendmail (My CentOS is installed using yum install sendmail), restart the php-fpm process and the sending fails.

Use the mail command in Shell for testing. The email can be normally sent without any problems. But the mail () function in PHP does not work.

Search for documents online and find that the sendmail component has been installed when compiling PHP. Otherwise, you cannot send emails. But I don't want to re-compile PHP once (too time-consuming). Is there any other way? -- The answer is yes, of course.

You only need to find the mail settings in the php. ini file and set the following parameters:

Sendmail_path =/usr/sbin/sendmail-t-I

That is to say, let the system find the absolute path of sendmail, so there will be no problem! Restart PHP to test email sending. Success !!

Reference: http://blog.csdn.net/zeropool/article/de

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.