Giving your visitors an easy way to reach you is a fundamental feature that every modern site should have. As such, having a working contact form is a must nowadays. In this article, we will show you how to set up a PHP contact form on your website and we will even provide you with a free PHP email script which you can download and use.

Is There a Difference Between PHPMailer and the PHP Mail() Function?

If you have previously researched how to connect your contact form to your email in PHP, you may have come across the terms PHP mail() function and PHPMailer. While they sound remarkably similar, these terms are in fact two distinct pieces of technology.

The PHP mail() function is a part of the standard PHP installation and is available out of the box. While it is very barebones in terms of features, it can still be used to create PHP mailer scripts. As such, the PHP mail() function works best when you need to send very basic email messages. For more information on the PHP mail() function, you can check our article on how to send emails using PHP mail().

The PHPMailer, on the other hand, is a free third party package for creating sophisticated PHP email scripts. PHPMailer needs to be downloaded separately and integrated into your website. It supports advanced features, not found in the standard PHP mail() function, such as the sending of attachments and the creation of richly formatted email messages thanks to built-in support for HTML markup and CSS styling.

The present article will show you how to create a PHP mailer script using the built-in PHP mail() function. If you are interested in using PHPMailer, you can check our article on how to create a contact form using PHPMailer.

What Are the Requirements to Have a Working PHP Mail Script for My Contact Form?

We strongly believe that a working contact form is a feature that every website owner should have access to, regardless of the hosting plan they use. As a result, we allow contact form PHP files to be created and used on both our free hosting plan as well as our paid hosting packages.

In addition to having an active hosting plan, you also need to own a fully-qualified domain. You can either purchase a premium domain name or use the Domain Manager section of the Control Panel to register a free .DX.AM domain. Once you have a fully-qualified domain present in your hosting account, head over to the Email Accounts section of the Control Panel and register an email account. This account will be used for the actual sending of email messages. Not sure how to create an email account? You can review our guide on how to create an email account.

How Do I Set up a PHP Contact Form on My Website?

As long as you have an active hosting plan and there is an email account present in your hosting space, you can proceed to implement the contact form. The contact form itself is comprised of two files – a PHP email script that handles the actual email sending and an HTML form which your site visitors use to send you a message. To set up the PHP email script and HTML form, follow the steps below:

  1. Go to the File Manager section of the Control Panel.
  2. Double-click on your domain name’s folder in order to open it.
  3. Click on the Create button, switch to the option to Create File and make a new HTML document. Name it contact.html as is shown in the screenshot below.