Domain and IP whois

Domains HostingHosting VPS HostingVPS / VDS SSLCertificates Company Company

VPS / VDS hosting >  Simple script to test the php mail function

Periodically, the task arises to check the work of mail for the site, this functionality is especially important for online stores, whose owners receive notifications of new orders by e-mail. If mail has ceased to come from the site, the first step is to check the operation of the php mail function (for sites on php). 

An example of a simple script to test the php mail function.

Create file test-email.php: 

ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = "test@DOMAIN.TLD";
$subject = "PHP Mail Test script";
$message = "This is a simple php script to check PHP Mail function";
$headers = "From:" . $from;
mail($to,$subject,$message, $headers);
echo "Good, test email sent";

Change test@DOMAIN.TLD and YOUMAIL@DOMAIN.TLD on your own, after which you can run the script.

Running a script from the console:

#php test-email.php

The script can also be run from the browser if you are using not a virtual server, but virtual hosting. Receiving a letter will mean that the php mail function is working correctly.

Client Area

Log in

Forgot Password

Sign Up

Check mail:


VPS Application catalog

Additional services

Knowledge base

VPS hosting

We were chosen by leading media companies with large volumes of data and high load

Calculate tariff

Domain transfer