On the linux server, we need to determine whether it can use the mail function in many ways. For example, we can use exists or phpinfo to check whether it can use the mail function. Here we will introduce these two methods.
Use the exists function to determine
Create a PHP file. The Code is as follows. Upload the file to the root directory of the website for access. Naturally, you will know whether the mail () function is supported!
| The Code is as follows: |
Copy code |
<? Php If (function_exists ('mail ')){ Echo "supports the mail () function! "; } Else Echo "does not support the mail () function! "; ?> |
Use a PHP file to send emails
The code for creating a new php file named mail. php is as follows:
| The Code is as follows: |
Copy code |
<? Php $ Txt = "hello "; // Change the email address below to yours $ Mail = "admin@lajiz.cn "; // Send an email Mail ($ mail, "My subject", $ txt ); Echo "message was sent! "; ?> |
If you use phpinfo, you only need to find the value of sendmail_path is/usr/sbin/sendmail-t-I, which proves that you can use the mail function. Otherwise, the mail function cannot be used.