Software, your way.
burger menu icon
WillMaster

WillMaster > LibraryTutorials and Answers

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Email Testing

It can be frustrating when a PHP script sends an email and it doesn't arrive in the mailbox where it is expected.

There are many points to check. Some are: Was it a valid email address? Did filters catch it? Is it just slow in arriving?

This article provides a script to check just one point — whether the server actually sends email.

Customize this script with an email address for testing. Put it on your server. Type its URL into your browser. The script will run the PHP mail() function to sent an email to the email address you specified.

<?php
// Test Email
// Version 1.0
// November 18, 2024
// Will Bontrager Software, LLC
// https://www.willmaster.com

// The email address, email subject, and email content to send the test email to.

$EmailAddressForTest = "name@isp.com";
$Subject = "The email test";
$Content = "AN Email test from {$_SERVER['PHP_SELF']}";

// No other customization required.

// Sending the email.
mail($EmailAddressForTest,$Subject,$Content,"From: $EmailAddressForTest");

?>
-Mailed-

Now, see if the email arrived. Allow sufficient time for the email to transport and get dropped off in your mailbox.

If no email arrives in the mailbox, try testing a different email address, one that is not on the same server as the email that was just tested.

If no email arrives for any email address you test, then it may well be the server that is not sending email. (That would be the server where the email testing PHP script is installed.) The reason could be for any number of reasons — server's IP address blacklisted, server doesn't allow the PHP mail() function to be used, hosting company is filtering out your email, … . At this point, it would generally be time to ask support for input. They may need a copy of the script.

If email arrives to at least one of the tested email addresses but does not arrive at other email addresses, then the server is sending the email. Instructions about what exactly needs to be done now about the email that did not arrive is outside the scope of this article. The actions probably will include testing for spam filters and verifying that each email address works when sent from a different emailer. Also check if the sending IP address is at a service that the destination server consults.

Debugging email can be frustrating. This article provides a script to test if one aspect is working as it should.

(This content first appeared in Possibilities newsletter.)

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC