You are viewing an old revision of this post, from August 7, 2015 @ 17:26:31. See below for differences between this version and the current revision.

Simple PHP Mail test


  • Access to your hosting via SSH or FTP


This is a handy little script to help test your hosting to ensure you can send emails from PHP based sites which include a contact form or similar. This includes CMS systems such as WordPress and Joomla as well as eCommerce platforms such as Magento.

If you have made changes (eg enabled SMTP in the PHP settings) or moved hosts, this is a quick way to be confident the emails are working.


  1. Create the test-email.php script with the following:
    1. <?php
    2. ini_set( 'display_errors', 1 );
    3. error_reporting( E_ALL );
    4. $from = "emailtest@YOURDOMAIN";
    5. $to = "YOUREMAILADDRESS";
    6. $subject = "PHP Mail Test script";
    7. $message = "This is a test to check the PHP Mail functionality";
    8. $headers = "From:" . $from;
    9. mail($to,$subject,$message, $headers);
    10. echo "Test email sent";
    11. ?>
  2. If you have a Virtual Private Server (VPS), login to the server to execute:
    1. php test-email.php
  3. Alternatively, place the file in your httpdocs directory so that it can be called from your website.
  4. Check your email to ensure it has been delivered.
  5. If you have the file publically accessible on your website, don't forget to delete it after testing is complete!


  • August 7, 2015 @ 17:26:31 [Current Revision] by admin
  • August 7, 2015 @ 17:26:31 by admin

Revision Differences

There are no differences between the August 7, 2015 @ 17:26:31 revision and the current revision. (Maybe only post meta information was changed.)

No comments yet.

Leave a Reply