Checks whether the linux VM/space supports the mail function.

Source: Internet
Author: User

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.

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.