-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact.js
32 lines (28 loc) · 1.13 KB
/
contact.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
document.getElementById('contactForm').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent the default form submission behavior
// Collect form data
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const phonenumber = document.getElementById('phonenumber').value;
const subject = document.getElementById('subject').value;
const message = document.getElementById('message').value;
// Initialize EmailJS
emailjs.init("tNJ1716vVd9rPzdJY");
// Prepare the email parameters
const templateParams = {
name: name,
email: email,
phonenumber: phonenumber,
subject: subject,
message: message
};
// Send the email using EmailJS
emailjs.send('service_l8zdly4', 'template_yd8ibzm', templateParams)
.then(function(response) {
console.log('SUCCESS!', response.status, response.text);
alert('Message sent successfully!');
}, function(error) {
console.log('FAILED...', error);
alert('Failed to send the message. Please try again.');
});
});