Bootstrap 5: Send Email from Contact Form

Ruth Jul 09, 2026

Creating a responsive contact form and sending emails using Bootstrap 5 can significantly enhance user experience and streamline communication. Bootstrap 5, the latest version of the popular CSS framework, offers numerous improvements and new features to help you build modern, mobile-first websites. In this guide, we'll explore how to create a contact form and send emails using Bootstrap 5 and its built-in JavaScript functionality.

37 Free Bootstrap Form Templates You Can Try Right Now
37 Free Bootstrap Form Templates You Can Try Right Now

Before we dive into the code, ensure you have the latest version of Bootstrap 5 installed. You can include it via CDN or download the files and host them locally. For this guide, we'll use the CDN version. Now, let's start building our contact form step by step.

Website Contact Form
Website Contact Form

Setting Up the Bootstrap 5 Contact Form

The first step is to set up the basic structure of our contact form using Bootstrap 5's grid system and form controls. We'll create a simple form with fields for name, email, subject, and message.

Contact Form UI Design | Lignt and Dark Mode | Boltstack.dev
Contact Form UI Design | Lignt and Dark Mode | Boltstack.dev

To start, include the Bootstrap 5 CDN links in your HTML file's head section:

```html ```

Creating the Form Structure

Contact Form Template | FormNX
Contact Form Template | FormNX

Now, let's create the form structure using Bootstrap 5's grid system and form controls. We'll use the `row` and `col` classes to create a responsive layout and the `form-control` class for input fields.

```html

```

Styling the Form

To make our form more visually appealing, we can add some custom styles using Bootstrap 5's utility classes and custom CSS. For example, we can add padding, background color, and border-radius to the form:

Bootstrap Fieldset Legend: How To + Examples + Template | AZMIND
Bootstrap Fieldset Legend: How To + Examples + Template | AZMIND

```html

```

Sending Email Using Bootstrap 5 and JavaScript

Now that we have our contact form set up, let's make it functional by sending emails using JavaScript. We'll use the Fetch API to send a POST request to a server-side script that will handle the email sending process.

First, include the following JavaScript code at the end of your HTML file to handle form submission:

an image of some type of webpage with different font and numbers on the page
an image of some type of webpage with different font and numbers on the page

```html ```

Replace `'/path/to/your/server-side-script'` with the actual path to your server-side script that will handle the email sending process. You can use a library like Nodemailer for Node.js or PHP's mail function for PHP to send emails from your server.

Handling Form Validation

40 Best Free HTML5 & CSS3 Contact Form Templates 2026 - Colorlib
40 Best Free HTML5 & CSS3 Contact Form Templates 2026 - Colorlib
the contact form
the contact form
20 Beautiful CSS Contact Forms Code Examples - OnAirCode
20 Beautiful CSS Contact Forms Code Examples - OnAirCode
Engage with Ease Through Our Info Card Blocks Contact Us Form
Engage with Ease Through Our Info Card Blocks Contact Us Form
20 Splendid CSS3 Web Forms Tutorials
20 Splendid CSS3 Web Forms Tutorials
MakeForms: All-in-One No-Code Form Creator & Automation Tool
MakeForms: All-in-One No-Code Form Creator & Automation Tool
an invoice form with orange accents on the front and bottom, as well as two
an invoice form with orange accents on the front and bottom, as well as two
How to Create Forms in monday work management | TechRepublic
How to Create Forms in monday work management | TechRepublic
Support and Contact Page Design
Support and Contact Page Design
Contact Form Template | FormNX
Contact Form Template | FormNX
the email form for bloomingdales is shown in black and white, with green accents
the email form for bloomingdales is shown in black and white, with green accents
Client Challenge
Client Challenge
web simple business email UI design template
web simple business email UI design template
Subscription form (inline template)
Subscription form (inline template)
the spotify homepage is shown with an email address to join and receive people
the spotify homepage is shown with an email address to join and receive people
Simple Email Design
Simple Email Design
How to add a contact on Zoom and other useful tips
How to add a contact on Zoom and other useful tips
Supercharge Your Google Forms and Get More out of Them
Supercharge Your Google Forms and Get More out of Them
X. It’s what’s happening
X. It’s what’s happening
Confirm your account
Confirm your account

To provide better user experience, we can add some basic form validation using Bootstrap 5's built-in JavaScript functionality. We'll use the `feedback` class to display validation feedback messages and the `is-invalid` class to indicate invalid input fields.

```html ```

Add the following HTML structure for each input field to include validation feedback messages:

```html

Please enter your name.
```

With this setup, users will receive immediate feedback when they enter invalid data in the form fields.

And there you have it! You've now created a responsive contact form using Bootstrap 5 and implemented email sending functionality using JavaScript. This form will provide a seamless user experience and help you collect valuable information from your visitors.

Remember to test your form thoroughly and ensure that your server-side email sending script is secure and reliable. Keep an eye on your inbox for any incoming messages, and don't forget to respond to your users promptly.

Now that you've mastered Bootstrap 5 contact forms, why not explore other features of the framework to enhance your web development skills? Happy coding!