on submit, i would like for the contents of this form to be sent to an email address, I am unsure of what to add to the function below for it to work effectively.
HTML
<div class="form-container" id="form-container">
<h2>Get a quote</h2>
<form id="contact" autocomplete="off" action="#">
<div class="form-field name-field">
<input type="text" id="name" placeholder="Full Name">
<div class="error"></div>
</div>
<div class="form-field">
<input type="text" id="email" placeholder="Email Address">
<div class="error"></div>
</div>
<div class="form-field">
<textarea rows="4" cols="50" id="comment" placeholder="Your Message" form="usrform"></textarea>
<div class="error text"></div>
</div>
<button type="submit" id="submit">Send Message</button>
</form>
</div>
<div class="form-container2 hide" id="form-container2">
<img src="assets/success.svg" alt="">
<h3>Message Sent</h3>
<p>Thanks for reaching out, our team will get back to you in the next 48 hours</p>
<button id="back" onclick="refreshPage()">Go Back</button>
</div>
JAVASCRIPT
form.addEventListener("submit", (e) => {
e.preventDefault();
field(user, 0, "Name cannot be blank");
field(msg, 2, "Message cannot be blank");
if (
!user.classList.contains("invalid") &&
!email.classList.contains("invalid") &&
!msg.classList.contains("invalid")
) {
location.href = form.getAttribute("action");
container1.classList.add("hide");
container2.classList.remove("hide");
}
});