Example contact form (form-to-mail).
Our servers require SMTP authentication, which in plain English means you will have to use any of your e-mail accounts, created within the E-mail Manager -> E-mail 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”;
$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 variable 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 variable than $email, depending on the contact form itself.
If you wish the messages from the contact form to be received in e-mail box which is not on our servers just replace the $mymail in the mail() function with the e-mail where the e-mails should be sent to.
Related posts:
- I am unable to use PHP mail() function from my paid hosting account, why?
- I can’t send e-mail. The error I receive is ‘Outlook is unable to connect to your outgoing (SMTP) e-mail server. If you continue receiving this message, contact your server administrator or Internet service provider (ISP).’
- How can I add an e-mail alias?
- I haven’t received my welcome email. What should I do?
- How can I create an e-mail account?

18. August 2009 at 8:08 pm :
The correct syntax to the CONTACT FORM is:
———————————————————————–
Contact form
Contact form
Subject:
Name:
E-mail:
Message:
———————————————————————–
26. August 2009 at 12:03 pm :
Hello admin,
i wonder any trail period in the free trail account. thank you
29. September 2009 at 12:57 am :
Where does the mailer.php file go in the file structure?
Cheers,
Matt
9. October 2009 at 10:06 pm :
This script is not working for me.
9. October 2009 at 10:47 pm :
I take back the last comment, I got it to work. The problem for (likely for many others) is that if you copy and paste the code into your html and php files from the tutorial above, the characters cet pasted in ANSI format. The Quotations marks are not in the correct format, and so I had to manually change them each individually.
4. January 2011 at 6:33 am :
What am I doing wrong? I have created a form with inputs and the action tag pointing to my mailer.php text file using the above code and uploaded the files to my site, but when I click Submit the page refreshes, the fields reset, and “&name=xxxx&company=xxx&subject=xxx…” is added to the end of my page’s url, but nothing else happens. No confirmation (or error) echo messages, no e-mail sent to me, nothing. Please help, as I have been trying to get this working for awhile now.
27. March 2011 at 11:17 am :
Hi
I tried to use this codes but I dont recieve email the message is :
Your message has been sent successfully!
but no email recieving.
thanks.
29. March 2011 at 11:51 am :
Hello @esi,
Where did you upload this contact form? If it is on our web hosting, please provide url, so we can check if everything is fine.