If you’re unsure as to whether or not your PHP server is configured for sending email, then this simple script is for you.
// FILE: test-email.php <?php ini_set( 'display_errors', 1 ); error_reporting( E_ALL ); $from = "firstname.lastname@example.org"; $to = "YOUREMAILADDRESS"; $subject = "PHP Mail Test script"; $message = "This is a test to check the PHP Mail functionality"; $headers = "From:" . $from; mail($to,$subject, $message, $headers); echo "Email test sent"; ?>
Upload the file and test
- Place the file in your public_html folder or where ever the root of your site.
- Go to: somedomain.com/test-email.php
- Ensure you received the test email
Important: Don’t forget to delete the file when you’re done testing, it’s publicly available.