Example Contact Form

Home » Knowledge Base » F.A.Q. » Email Management » Example Contact Form

Our servers require SMTP authentication, which in plain English means you will have to use any of your email accounts, created within the Email Manager > Email Accounts section from your control panel.
You can see the code of an example contact form below(contact.html):

<html>
<head>
<title>
Contact form
</title>
</head>
<body>
<center>
<font size="5">
<b>
Contact form
</b>
<br>
<br>
</font>
<form method="POST" action="mailer.php">
Subject:
<input type="text" name="subject" size="20">
<br>
<br>
Name:
<input type="text" name="name" size="20">
<br>
<br>
E-mail:
<input type="text" name="email" size="20">
<br>
<br>
Message:<br>
<textarea rows="9" name="message" cols="30">
</textarea>
<br>
<br>
<input type="submit" value="Send" name="submit">
</form>
</center>
</body>
</html>

To have the form working you will also have to create a file called mailer.php with the below code:

<?php
if(isset($_POST['submit'])) {
$myemail = "youremail@yourdomain.com"; Caution: replace youremail@yourdomain.com with a vaild one you created in Email Manager
$subject = $_POST['subject'];
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$headers = "From:Contact Form <$myemail>\r\n";
$headers .= "Reply-To: $name <$email>\r\n";
echo "Your message has been sent successfully!";
mail($myemail, $subject, $message, $headers);
} else {
echo "An error occurred during the submission of your message";
}
?>

If you already have a non-working contact form try adding the following variables and check if it works:

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

NOTE: The Reply-To header could be set with different variables than $email, depending on the contact form itself.

If your contact form already has the $header or $headers variable you will have to add the code with the following change:

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

NOTE: The Reply-To header could be set with different variables than $email, depending on the contact form itself.

If you wish the messages from the contact form to be received in an email box that is not on our servers just replace the $mymail in the mail() function with the email to where the emails should be sent to.

Was this post helpful?

i

Relevant tags:

Connect

Latest posts:

How to Install MediaWiki

You can quickly install MediaWiki on any of the AwardSpace web hosting plans. This includes our free web hosting, shared hosting, as well as advanced services such as semi-dedicated hosting and VPS hosting. You can install MediaWiki in a matter of minutes, whichever...

How to Install an Elgg Theme

After you have installed Elgg core and logged in to the admin dashboard, you can search for themes that can help you customize your new website. Elgg themes are a set of files that help you customize the appearance of your website. Via themes, you can modify website...

How to Log in to Elgg

After you install Elgg, it is time to log in to the CMS, so you can start working on your Elgg website. To log in, you should load the Elgg login page and type in your credentials to access the platform’s admin dashboard. In the following paragraphs, we share how to...

How to Install Elgg

You can quickly install Elgg with any of the AwardSpace web hosting plans. You can use our free web hosting, shared web hosting, or advanced hosting plans such as semi-dedicated hosting and VPS hosting.   How to Install Elgg To install Elgg, you should first sign...

How to Change the PHP Timezone

Setting the correct timezone in PHP is crucial for ensuring that date and time functions in your scripts operate accurately. AwardSpace offers a range of hosting plans that provide easy management of PHP settings, including timezone configuration. This article will...



Create a website for free!


Free forever

Our Support Team is Here to Help

 

If you need any questions answered, don't hesitate and contact us. Click the button below and follow the instructions. You can expect an answer within an hour.

 

Contact AwardSpace

 

iNewest knowledge base articles

How to Install MediaWiki

You can quickly install MediaWiki on any of the AwardSpace web hosting plans. This includes our free web hosting, shared hosting, as well as advanced services such as semi-dedicated hosting and VPS hosting. You can install MediaWiki in a matter of minutes, whichever...

How to Install an Elgg Theme

After you have installed Elgg core and logged in to the admin dashboard, you can search for themes that can help you customize your new website. Elgg themes are a set of files that help you customize the appearance of your website. Via themes, you can modify website...

How to Log in to Elgg

After you install Elgg, it is time to log in to the CMS, so you can start working on your Elgg website. To log in, you should load the Elgg login page and type in your credentials to access the platform’s admin dashboard. In the following paragraphs, we share how to...

How to Install Elgg

You can quickly install Elgg with any of the AwardSpace web hosting plans. You can use our free web hosting, shared web hosting, or advanced hosting plans such as semi-dedicated hosting and VPS hosting.   How to Install Elgg To install Elgg, you should first sign...

How to Change the PHP Timezone

Setting the correct timezone in PHP is crucial for ensuring that date and time functions in your scripts operate accurately. AwardSpace offers a range of hosting plans that provide easy management of PHP settings, including timezone configuration. This article will...

How to Disable PHP Error Messages

When running a PHP-based website in a production environment, it's crucial to disable PHP error messages to prevent sensitive information from being exposed to users. AwardSpace offers a variety of hosting plans tailored to different needs, all of which support...

Even more web tutorials

Check out our web hosting knowledge base and the WordPress tutorials to learn more, and be better prepared for your website creation and maintenance journey.