Before that server transferred, found that the Web site with mail () sent to send mail. But found SendMail has been installed.
If SendMail is not installed, you can perform
The code is as follows |
Copy Code |
Yum Install SendMail |
Yes, the host name should be formatted with a domain name. For example: sangsir.com
Otherwise, it will take a long time to restart the sendmail. (otherwise it will be a long wait)
The code is as follows |
Copy Code |
Hostname sangsir.com
|
Then see if SendMail is working properly.
The code is as follows |
Copy Code |
Service SendMail Status
|
Can start if it is not running. Status replaced by Start
Immediately thereafter, the editor php.ini. You can create a phpinfo in a Web environment
Because I'm using a lnmp.
Vi/usr/local/php/etc/php.ini
And then find:
; Sendmail_path =
By I edit, replace with:
The code is as follows |
Copy Code |
Sendmail_path =/usr/sbin/sendmail-t-I. |
My system defaults to:
Sendmail_path =/usr/sbin/sendmail-t-i-f
This-F appears to have the mail function deactivated, and the mail function has been restored to normal after the-F has been removed.
Immediately thereafter, restart the PHP process.
Generally: Service PHP restart
LNMP is: Service php-fpm restart
Apache can: Service httpd restart
To share a PHP script test code:
The code is as follows |
Copy Code |
<?php $send = Mail (' yourEmail@lisizhang.com ', ' message header ', ' test message content, if received, indicates mail function successfully enabled! ’); if ($send) { Echo ' true '; }else{ echo ' false '; } ?> |
If the return result false indicates that the message sent failed, if TRUE indicates that the message was sent successfully!