How to configure Contact Form hosted with us

Email Service. Benefits and possible issues

Email account should be created on our hosting server

FROM field in PHP script for mail form

Contact Form VS WordPress

Contact form VS another CMS

Email Service. Benefits and possible issues

Email has become an integral part of our lives. This simple service has closed distances and brought the world together. Other countries do not seem to be that far away anymore because communication has become that much faster. It helps to save both time and money.

Email service becomes a powerful advertising tool as well. It allows you to form a circle of loyal customers and boost business performance. But unfortunately, with the number of benefits come issues as well. Spam, spam-advertising, fraudulent and phishing messages, etc.

Probably the main issue that email service providers face is spam. Therefore, email service providers and hosting companies have to manage different anti-spam services/ filters and put a restriction in order to prevent sending spam from their servers and protect their customers and other users.

Our email service is configured to check public spam lists, such as SpamCop, Spamhaus, etc. We also have SpamAssassin installed on our servers which you can easily enable and configure through your cPanel. Check the How to configure SpamAssassin article for more information. Recently we have implemented a new feature on our shared servers called Rewrite From Header. It was done to improve the validation of email senders on our servers that will allow us to deal with spamming activity more efficiently in this way.

Also, we have disabled sending emails from the email address on the domain that does not exist on the server or uses third-party email service at the moment. We have taken these measures due to mass SPAM sending through forums, guest books, and contact form scripts on our servers.

And since many customers have contact forms at their websites configured for using third-party email accounts or services, sometimes it might have resulted in the improper functioning of mail forms and similar services, unfortunately.

Sometimes when you use Gmail, Outlook or Yahoo email address on a website contact form, the attempt to access your account may be blocked. This is because some of the most popular free email services reject successful login attempts, originating from unusual locations.

In this guide you will find tips and tricks on how to temporarily disable this restriction or add our server to the whitelist. The instructions provided in this article should help you to create and smoothly use your contact form for a website hosted with Namecheap.

Email account should be created on our hosting server

If you have a PHP mail contact form, it sends emails from our server to your account. But to send emails from our server, the domain should be added to it and have MX records pointed to the server where this domain is hosted. So if you use Google Apps, Wix or any other third-party services for your domain, it will not be possible to send emails from our server using this domain name.

You may point your domain to our server’s MX records, or you can leave custom records for your domain and use third-party service with it. But then create a subdomain and point it to our server’s MX records.

And then you can use in your php form with email account created using your subdomain.

You can manage your records in the cPanel >> the Zone Editor and Email Routing menus:

1. For domain you are going to use with your mail form Email Routing should be set to Local Mail Exchanger. To configure the routing, go to the Email section in cPanel >> the Email Routing menu:

If you have several domains or subdomains, choose the needed domain from the drop-down list and set Email Routing to Local Mail Exchanger >> click Change:

2. You may create MX record pointed to your main domain (if it is pointed to the server IP) or directly to the server. You can find server name using this article.
To edit MX records, go to the Domains section and click on the Zone Editor menu:

3. To edit a domain DNS zone, click the Manage button next to this domain:

Choose the MX option and add or edit the MX records:

This is the first and main condition for sending emails from the hosting server. With these settings, your domain is correctly pointed to hosting server’s mail service and ready to use PHP mail form.

FROM field in PHP script for mail form

In order to avoid issues related to spam, it is possible to use email hosted at our servers in FROM field. So, as a result, you create contact form only using REPLY TO field for the domain which is not hosted with us and FROM field for the domain name hosted on our servers in mail headers.

If you have PHP script for mail form, you need to change your script's settings. In order for your scripts to work as intended, you need to set the FROM field to an email address that you have created under your cPanel account.

We will use from@yourdomain.tld email address as an example further. Regularly PHP scripts have settings similar to the following ones:

$email_from = $_POST['email'];
$email_from = "";
$headers = "From: $post_email"; etc.

All these values use some third-party emails or variable values with email taken from 'your email address' field in the contact form.
Thus you may set From: or $email_from to use email account created on the server as it is described above.

Below you can check the sample of a simple code you can use in the PHP script to create your mailform:

$mail_to_send_to = "name@anydomain.tld";
$your_feedbackmail = "from@yourdomain.tld";
$sendflag = $_REQUEST['sendflag'];                       
if ( $sendflag == "send" )
                $email = $_REQUEST['email'] ;
                $message = $_REQUEST['message'] ;
                $headers = "From: $your_feedbackmail" . "\r\n" . "Reply-To: $email" . "\r\n" ;
                $a = mail( $mail_to_send_to, "Feedback Form Results", $message, $headers );
                if ($a)
                     print("Message was sent, you can send another one");
                } else {
                     print("Message wasn't sent, please check that you have changed emails in the bottom");

  Your Email:




It creates a simple contact form window:


1. In 'Your Email' field visitor can specify 'feedback' email and it will be sent in 'Reply To'. So once you click on 'reply to' in your email client – address from this field will be set.

$email = $_REQUEST['email'] ; - is where email is set

Reply-To: $email" . "\r\n" ; - is string to put this address in 'Reply To'

2. Message will be sent to name@anydomain.tld email address as it is set in:

$mail_to_send_to = "name@anydomain.tld";

And from from@yourdomain.tld according to:

$your_feedbackmail = "from@yourdomain.tld";

Also, you can use a simple contact form configured for our servers.

Contact Form VS WordPress

WordPress powers approximately 50% of all the websites online around the world. So contact form for WordPress is a very important tool as well.

We recommend that you use the Contact-Form-7 plugin for creating contact form at your WordPress site. Contact Form 7 can manage multiple contact forms, plus you can customize the form and the mail contents flexibly with simple markup. The form supports Ajax-powered submitting, CAPTCHA, Akismet spam filtering and so on.

By default, this plugin sends email from default cPanel email account. However, if you use some other plugin and face any issues with the contact form, you can install an SMTP plugin to force your WordPress to send emails from the account created on the server.

You can use the WP-Mail-SMTP plugin. It reconfigures wp_mail() function to use SMTP instead of mail() and creates an options page that allows you to specify various options:


From Email: you can specify the email address from which emails are sent, it should be created in your cPanel account
From Name: name displayed in the emails sent
Mailer: select Send all WordPress emails via SMTP.
SMTP Host: localhost (or specify servername, you can find server name with this article)
SMTP Port: 465 for use SSL encryption and 587 for use TLS option
Authentication: Yes, use SMTP authentication
Username: full emails address same as From Email
Password: password from this email account

With these settings, your WordPress plugins should send emails from our server correctly.

Contact form VS another CMS

Actually, settings for most CMS are similar to WordPress and SMTP plugin. We will show an example with MotoCMS and contact form plugin for this content management system:


Email Source: this field is for email account hosted with Namecheap and created in cPanel
Email to: here you can specify email account where all messages from contact form will be sent, it could be any address hosted on the server or not
Use SMTP server: should be checked
Port: 465 (and then Secure SMTP connection SSL)
Authentication type: login
SMTP Username: full emails address same as From Email
Password: password from this email account

That's it!


                      Need any help? Contact our HelpDesk

53621 times

Need help? We're always here for you.