Hosting Knowledge Base

Home » Knowledge Base » General Information » How-To » How to get an existing contact form to work?

Knowledge Base

Sign up for FREE now!

How to Get an Existing PHP Contact Form to Work?


If you have a PHP contact form that is unable to send messages, try the solution provided below.

Open your contact form’s PHP file in a text editor and insert the following code into it:

 $mymail = '';
 $headers = 'From: Contact Form <$myemail>\r\n';
 $headers .= 'Reply-To: $name <$email>\r\n';
 mail($mymail, $subject, $message ,$headers);

Save the changes you have just made, and then run your script in a browser to test its sending capabilities.

Note: Make sure you replace with a valid e-mail address created through our system. If you have not yet had a chance to set up an e-mail address on your AwardSpace mail server, please review our How to create an email account? article for more information on how to craete an e-mail ID.

The above code basically sets the e-mail address entered in the contact form to be set as “Reply-To” header and you set your e-mail address created through our system as a sender (“From” header).

It is important to note that these changes need to be added to the $headers variable, so it is vital that you add them to the PHP mail() function.

If your PHP script already contains the $header or $headers variables, you will have to add the same code but with a small tweak:

 $mymail = '';
 $headers .= 'From: Contact Form <$myemail>\r\n';
 $headers .= 'Reply-To: $name <$email>\r\n';
 mail($mymail, $subject, $message ,$headers);

Basically, you will need to put a dot (.) between the $headers variable and the equal sign.

Again, make sure you replace with a valid AwardSpace e-mail account.