Contact Form Send to Multiple Emails in PHP

Last Updated on February 15, 2023 by Roshan Parihar

In this tutorial, learn how contact form send to multiple emails in PHP. You can add as many recipient email addresses as you want to send emails to them.

When you have multiple recipients who want to receive contact form data via email, you can use this type of contact form on your website.

Contact Form Send to Multiple Emails in PHP

Bonus Tip

Looking to create contact forms to send emails to multiple recipients without coding? Create beautiful-looking contact forms with JotForm.

You can send emails to the website, owner, team members, and others. It can help your business to handle queries faster and increase performance.

So, let’s find out how you can create a contact form to send users’ submitted data to multiple email addresses using PHP.

How to Create Contact Form Send to Multiple Emails in PHP (Step-by-step)

Here is the step-by-step process on it:-

Step 1: Create Contact Form Design

HTML Page Code

First, Create the basic structure of the HTML page. Let me help you with the example HTML page code given below.

Contact Form HTML Code Structure

After that, create a design for the contact form with input fields required to collect information about users. We need basic information like Name, Email, and, Message.

The ‘Name’ field is used to send an email with personalization (like Hi Rohan). The ‘Email’ field is useful to reach users via email and communication with them. The ‘Message’ field is useful to collect queries from the customers for which they want to contact us.

The overall structure of the contact form is as shown in the HTML code below. Place the below form code to the above HTML page code location indicated.

CSS Code to Make Better Contact Form Design

Also, the above HTML code is not enough to create a better design of the contact form. You have to add some CSS code that can improve your contact form fields and button design. Place the below CSS code to the HTML page code

Now, your contact form design is ready to add to your website as shown in the image below.


But, before adding it to your website, you have to add some PHP code to send contact form data via emails to multiple recipients.

Step 2: PHP Code to Send Contact Form Data Via Emails to Multiple Recipients

To send the contact form data to multiple email addresses, you have to just add comma-separated email addresses inside the $to variable. After that, pass the variable to the mail() function as given in the PHP code below.

You have to first collect the form data using $_POST global variable. After that, you can validate the email address using the regular expression and preg_match() function.

If you want to make every field required for users to fill, you have already added required attribute to each field in the HTML code above. So, there is no need to make fields required using extra PHP code.

Tips: Use isset() function to execute the PHP code only when your users fill out the form and click the submit button.

After that, use the mail() as given in the PHP code below to send emails. The first variable of the function should contain multiple comma-separated variables. If you want to send emails using PHPMailer Gmail SMTP, you can read our post on Contact Form Using PHPMailer Gmail SMTP to Send Emails.

Let’s move further to send emails to multiple recipients using mail(). See further code of the PHP given below as each line are well commented to help you easily understand them.

Explanation of the PHP Code to Send Multiple Emails

Let’s understand each variable to send emails using PHP code:-

  • $to: You can place multiple recipient email addresses in comma separation to send emails to them.
  • $subject: The main subject of the email.
  • $message: The main content body of the email or query the customer’s businesses want to receive.
  • $headers:
    • 'From': the email address of the website owner that should be domain specific.
    • 'CC': the email address of the second person who wants to receive emails.
    • "Reply-To': the email address of the user who fills out the contact form.
  • mail(): It is the built-in function of PHP to send emails. It required 4 variables to pass as an argument. The 4 variables are $to, $subject, $message, and $headers.

If you have any queries regarding the above tutorial, please comment below. I will reply to help it.

You May Also Like to Read

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.