How to get your WP Site contact-form working?

Table of Contents

New to WordPress and wondering how to get your WordPress website’s contact form working? or have you spent your whole day figuring out what would work for you? Well contact forms configuration might be hectic of a task but can be achieved easily. We bring you best practices on how to get your WP Site contact-form working so you don’t have to worry about it!

In today’s post we are going to check what is contact form? why contact form matters and how to get contact form working for your site using SMTP and PHP method. Without further delays, lets find out!

What is a contact form?

Well straight to the point a contact form is a digital form. In short it is a way how a website visitor / users can digitally fill a form to contact the respective website admins over the Internet. The contact form is an advanced form present on website for general queries which then used to address further. Contact forms can be of many means, such as an enquiry for quotation, product billing enquiry, general or an appointment enquiry etc.

Why contact form is necessary?

Contact form on a Website does signify many things. One of the main important message a contact form presence gives your visitors that you care about thier queries. Having a contact form would also help you understand your visitor patterns, how and what they are indicating in the form can help you make further strategies and help you know the environment.

Mind that you are presenting something on your website and the visitors have queries about it? that’s a job contact form gets done for you. Contact forms are very important section of your website because of the nature how it works. Contact form can be a boon to the sales and so forth. For all such reasons it is very necessary to keep an easy contact form.

How to get contact form working?

Of course we live in 2023 and everyone is aware about such basic terms and how these things are done. However, there are times when we begin our website and get our moral down when we map the road towards completing it. Now a days almost all WordPress themes provides a default form in basic format which you can change it later. You also get the chance to design your custom form using many available contact form plugins present and later integrate it in your web page.

Before we get into the details, we thought its a good idea to walk you through how these things work internally.  Note that we will be checking 2 ways to get your WordPress website contact form working. One is PHP script and the other is using a SMTP plugin on your WordPress instance to get it work. Review the following screenshot.

As you can see in the screenshot the PHP method would be a script having the necessary coding.  Script make use of a mail function which is already coded in your WordPress instance and then uses the details to pass through email relay server. In the right hand section of screenshot you can see a SMTP plugin doing the same job, the difference here is you need not to have PHP mailer script when you are using SMTP plugin.

PHP mail() function method

This method is called as PHP method because here you have to create / upload a well written PHP script. This PHP script is written in PHP language and uses mail () function to get the contact form through a relay server of your hosting. Here is a sample PHP mailer script you can use for contact form.





<form method="post">


<input type='text' name="name" placeholder="Name" />


<input type='text' name="email" placeholder="Email" />


<input type='text' name="subject" placeholder="Subject" />



<textarea name="message" rows="5" placeholder="Type Message">



<input type="submit" name="go" value="Submit" />

$mailto = ""; //your email

$name = $_POST['name']; //getting visitor name

$fromEmail = $_POST['email']; //getting visitor email

$subject = $_POST['subject']; //getting subject line from visitor

$message = "Cleint Name: " . $name . "\n"
. "From Email: " . $fromEmail . "\n\n"
. "Client Message: " . "\n" . $_POST['message'];
$headers = "From: " . $fromEmail; // Client email, I will receive

$retval = mail ($mailto,$subject,$message,$headers);

if( $retval == true ) {
echo "Message sent successfully...";
}else {
echo "Message could not be sent...";

Copy the script and put it in your file called it mailphp.php. You would have to update this script as per your details and requirement. Make sure you upload the script in the path (document root) of your website being hosted. You can check the document root by following the steps here.

Note: This PHP mail script that I have used is very basic, this is just to give you a hint towards using this approach. You are requested to change this script as per your requirement and website design. This mail function approach isn’t much reliable and has higher chances of getting into spam. I would not recommend you go for this unless yo know what you are doing. If you wish to know more customized contact from that uses mail () function, check the awesome tutorial here.

SMTP plugin method

This method is more simple than PHP mail () function method. You would need a SMTP Plugin and  your hosting relay server setting such as port, authentication, encryption and host, server. We will be using WP mail SMTP plugin for this approach. This is far more easier to achieve than method 1. WP Mail SMTP plugin utilizes wp_mail() function with Gmail/Mailgun/SendGrid/SMTP.

Login to your WP admin, navigate to your Plugin section > add new plugin  > search SMTP > install > activate. We assume by this time you have already designed your contact form. WP Mail SMTP also works with other WordPress form plugins like Contact Form 7, Gravity Forms, Ninja Forms etc.

Post activating the plugins, navigate to its setting through hovering it on plugin  settings > Do basic setup > select other smtp > fill out the details shared by your hosting provider.

Note: You would have to grab the relay server details by contacting your hosting provider. Every hosting provider has thier own custom settings made for thier customers. By contacting them you would have to ask “what is the relay server setting for using SMTP for form mailer?” and they should answer.


Receiving submission forms throgh contact form would help you get to know the type of visitors visit your website and thier queries. If you setup the same email on your mobile then you wouldnt need to login to your webite to verify whats with it. What a saver right? This concludes how to get your WP Site contact-form working. What method worked for you? do let us know in the comments section below. If you need any help or have any suggestions to make, do reach us via contact page here. Happy Facebook’s Birthday!

Picture of Pranav Chaudhari
Pranav Chaudhari
I am a tech enthusiast who began a career in the hosting field. I like to help folks with their tech-related concerns and bring the best of it.

One Response

Leave a Reply

Your email address will not be published. Required fields are marked *

Send Us A Message

More Posts

This website used cookies to ensure you get the best experience in our website.