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 Find Modules in MediaWiki

After you install MediaWiki, log in to the CMS, and presumably install extensions, it is time to learn how to find modules in MediaWiki.   What are MediaWiki Modules Modules in MediaWiki are Lua-based scripts that allow you to add various functionalities to your...

How to Fix MediaWiki Internal Error: A Step-By-Step Guide

MediaWiki Internal Error message can be very frustrating and can significantly harm your MediaWiki project. Luckily, the issue can be fixed in a few easy-to-follow steps to get your website up and running in no time. There are various causes for the issue: Incorrect...

How to Add Infobox Module in MediaWiki

The Infobox in MediaWiki is a handy tool for presenting content and key information in a structured and visually pleasing way. Infoboxes are useful for any kind of MediaWiki project and can provide your readers with a quick snapshot of important data and details. In...

How to Install a MediaWiki Skin

In MediaWiki, skins determine the visual appearance of your wiki website. Skins define how content is presented to users and include such settings for the overall website layout, typography, color scheme, and more. By default, when you install MediaWiki, the platform...

How to Create a Page in MediaWiki

Creating pages in MediaWiki is а core feature that allows you to add content to your MediaWiki website. Whether you are adding details for a project, contributing to a knowledge base, or anything else, learning how to create a page in MediaWiki is crucial for your...



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 Find Modules in MediaWiki

After you install MediaWiki, log in to the CMS, and presumably install extensions, it is time to learn how to find modules in MediaWiki.   What are MediaWiki Modules Modules in MediaWiki are Lua-based scripts that allow you to add various functionalities to your...

How to Fix MediaWiki Internal Error: A Step-By-Step Guide

MediaWiki Internal Error message can be very frustrating and can significantly harm your MediaWiki project. Luckily, the issue can be fixed in a few easy-to-follow steps to get your website up and running in no time. There are various causes for the issue: Incorrect...

How to Add Infobox Module in MediaWiki

The Infobox in MediaWiki is a handy tool for presenting content and key information in a structured and visually pleasing way. Infoboxes are useful for any kind of MediaWiki project and can provide your readers with a quick snapshot of important data and details. In...

How to Install a MediaWiki Skin

In MediaWiki, skins determine the visual appearance of your wiki website. Skins define how content is presented to users and include such settings for the overall website layout, typography, color scheme, and more. By default, when you install MediaWiki, the platform...

How to Create a Page in MediaWiki

Creating pages in MediaWiki is а core feature that allows you to add content to your MediaWiki website. Whether you are adding details for a project, contributing to a knowledge base, or anything else, learning how to create a page in MediaWiki is crucial for your...

How to Install MediaWiki Extensions

Now that you have installed MediaWiki and learned how to log in to the CMS, it is time to extend MediaWiki's functionality via extensions. MediaWiki extensions are sets of files that add various types of functionality to your MediaWiki website. You can use extensions...

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.