Hosting Knowledge Base
PHP Mail Function
In this tutorial, we are going to provide instructions on how to set up a PHP script on your AwardSpace web server and send emails with it.
How Can I Check if the PHP Mail Function is Enabled on my Server?
To see if your web hosting account has PHP mail() enabled, follow these three simple steps:
- Create an empty PHP file in your hosting space (e.g. phpmailfunction.php) and place it in the root directory of your web site.
- Open the file you have just created, and copy and paste the below code into it:
- Run the script by accessing the web page in a browser. This should be the URL where you have uploaded your PHP document (e.g. http://yourdomain.com/phpmailfunction.php).
If PHP mail() is enabled on your web hosting server, you will receive a message similar to this:
If the outlined function does not exist in PHP, you will get the following reply from our server:
How Can I Test the PHP Mail Function?
On our shared hosting platform, the PHP mail() function only works if the from: address is an e-mail address registered within our system. This means you will need to create an e-mail account from the Control Panel, and then use it as a sender in your PHP mailer script.
You can test the PHP mail function on your AwardSpace server by following the below mentioned process:
- Register an e-mail account in our system. If you are unsure how to set up an e-mail address on your server, please review our How to create an email account? tutorial.
- Create a new PHP file in your domain directory (e.g. mailerscript.php).
- Using our File Manager, open the PHP document you have just created, and insert the following piece of code into it:
- Run the PHP mailer script (e.g. http://yourdomain.com/mailerscript.php) in your favorite Internet browser.
Note: Make sure your replace
email@example.com with your AwardSpace e-mail address. Otherwise, the mailer script will not be executed properly.
If the test is successful, your browser will display a E-mail message sent! message. You’ll also get an email from our mail server at the specified recipient (to:) address, as illustrated below:
If, for some reason, the above PHP script cannot be executed, you should check your code for any programming/syntax errors or contact our dedicated Support team for assistance.