There seems to be an issue with the emailJS library. Despite creating a function to send a copy of a transaction via email using emailJS, there is no response from the API and nothing showing up in the console.log. It appears that the function may not even be getting called. I can't pinpoint what went wrong, but I suspect it's a simple fix that I might have missed.
Below is the config.js file which includes user keys and the mailer function. I've removed the keys for privacy reasons:
// Function to send email
function sendEmail(name, address, city, state, zip, phone, email, amount) {
// Initialize EmailJS with your user ID
emailjs.init("public-key-here");
// Create the email parameters
var templateParams = {
name: name,
address: address,
city: city,
state: state,
zip: zip,
phone: phone,
email: email,
amount: amount
};
// Send the email using EmailJS
emailjs.send("service_ID", "template_ID", templateParams)
.then(function(response) {
console.log("Email sent successfully");
alert("Mail sent successfully");
}, function(error) {
console.log("Email failed to send", error);
alert("Error sending mail");
});
}
Here is where the send email function is being called on the payment page:
// Send email and save order details
sendEmail(name, address, city, state, zip, phone, email, amount);
localStorage.setItem('orderDetails', JSON.stringify({
amount: parseFloat(amount),
name: name,
address: address,
city: city,
state: state,
zip: zip,
phone: phone,
email: email
}));
I am not receiving any output in my console.log or alerts indicating whether the email was successful or not. Any assistance would be greatly appreciated.