forked from PriyaGhosal/SkillWise
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemail.js
More file actions
18 lines (15 loc) · 651 Bytes
/
email.js
File metadata and controls
18 lines (15 loc) · 651 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Initialize EmailJS service with the user ID
(function () {
emailjs.init(CONFIG.USER_ID_KEY);
})();
// Function to handle the form submission and send email
document.getElementById('contact-form').addEventListener('submit', function (event) {
event.preventDefault(); // Prevent the default form submission
// Send email via EmailJS
emailjs.sendForm(CONFIG.SERVICE_ID, CONFIG.TEMPLATE_ID_KEY, this)
.then(function () {
alert('Email sent successfully!'); // Success message
}, function (error) {
alert('Failed to send email. Error: ' + JSON.stringify(error)); // Error message
});
});