After the Linux system is configured with the lnmp environment, there is a problem that the mail function cannot send mail. How to solve this problem? In fact, there are two ways, one is to use the sendmail component, but to use postfix, the specific with the small series to understand it.
a method of using a mail to sendmail component
1. sendmail component mounting
yum install sendmail
2. Use the following command Restart php-fpm process
/etc/init.d/php-fpm restart
3. Check if sendmail is working properly
/etc/init.d/sendmail status
If you show that running is running.
Commands that may be used
/etc/init.d/sendmail start (starts sendmail)
/etc/init.d/sendmail stop (closes sendmail)< Br>
/etc/init.d/sendmail restart (restart sendmail)
4. Configure php.ini, fill in the absolute path of sendmail
Open the edit php.ini using the command< Br>
vi /usr/local/php/etc/php.ini
Enter? Sendmail_path find the location (or manually jump to find sendmail_path), you will find the default is the following code
; sendmail_path =
Press i to enter the edit, modify this line to
sendmail_path = /usr/sbin/sendmail -t –i
Press Esc to quit editing, type:wq to save and exit
5. Restart php-fpm process
/etc/init.d/php-fpm restart
This is a success. If you don't worry, create a new php file named mail.php, you can use the following code to test it.
"? Php
$txt = “hello,you are a good boy! ”;
//Change the following email address to your
$mail = ‘[email protected]’;
//send mail
mail($mail, “My subject”, $txt);
echo ‘message was sent! ’;
? 》
Save and upload to your website root directory and run it in your browser:
http://your URL/mail.php
When is your time? The mailbox should be able to receive the mail, but basically in the spam, pay attention to check, if you can not receive the mail, check the normal operation process, there is a restart of sendmail or restart php. In general, you will receive your mail normally.
Of course, the function is implemented, but when tested with the above test code, it is found that sending a message successfully is very slow and slow, it takes dozens of seconds or even a minute. Then I posted or replied to the comments on the blog, which was unusually slow, exceeding the psychological deadline for the user to wait. It is imperative to optimize this efficiency, otherwise it can only be cut off.
There are many online methods. Modifying this file is a modification of the file. It feels more troublesome, so I found the least modified operation and then succeeded.
Modify /etc/hosts, before modification
127.0.0.1 localhost.localdomain localhost
Modify to
127.0.0.1 localhost.localdomain localhost Host Name
The command to view the host name of this machine is: hostname
Restart the sendmail after completing the modification
service sendmail restart
2 pages
The Linux tail command is mainly used to display the last lines of the archive file
Some Linux users do not know how to set the read access of the .net iis metabase, then how to solve
In Linux system operation, logwatch can analyze the system log report for Linux log processing. The
Most Linux systems come with on-screen protection, while a few systems dont. For ex
How Linux uses the OpenSSL command line
Linux uses shell batch conversion file encoding method
The specific usage of the tee command in Linux system
Application of mkdir command in Linux
Ubuntu how to choose IPv4 or IPv6 channel when using apt-get update
How to configure the zabbix alarm function of Linux system?
What should I do if Ubuntu fails to adjust and save the screen brightness?
How to use Linux commands to view CPU usage
Ubuntu disk space is insufficient to clean up the boot partition
Linux software lacks dynamic link library. So what to do?
How to use the tail command guide under Linux
Linux uses xfs when there is no disk space. How to deal with
Win 8 system message reminder settings
Teach you how to sneak Jingdong 618 red envelope
Win7 system opens the local connection property prompt "some controls are disabled" how to do
About the security permissions configuration list
How to make Win8 file explorer display full path
What if Win10 can't access the D drive?
Personality by me: add pattern