79200022

Date: 2024-11-18 13:07:12
Score: 0.5
Natty:
Report link

Solved! Attached the sendEmail function to an event and used e.preventDefault() to prevent the default form submission behavior:

emailjs.init({ publicKey: '*' }); 

const sendEmail = (e) => { e.preventDefault();

var emailData = {
    name: 'Konstantinos Iakovou | Web developer',
    notes: 'Check this out!',
};

emailjs.send('service_*', 'template_*', emailData).then(
    (response) => {
        alert('Message successfully sent!');
    },
    (error) => {
        console.error('Failed to send the message:', error);
        alert(`Failed to send the message: ${error.text}`);
    },
);

};

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: konstantinosiakovou