Merge pull request #14 from ragusa-it/fix-emailjs-config-10566427372995944214
fix(emailjs): send emails sequentially and add reply_to
This commit was merged in pull request #14.
This commit is contained in:
@@ -71,28 +71,29 @@ export function Contact() {
|
|||||||
email: formData.email,
|
email: formData.email,
|
||||||
title: formData.subject,
|
title: formData.subject,
|
||||||
message: formData.message,
|
message: formData.message,
|
||||||
|
reply_to: formData.email,
|
||||||
};
|
};
|
||||||
|
|
||||||
await Promise.all([
|
|
||||||
// Send to Admin
|
// Send to Admin
|
||||||
emailjs.send(
|
await emailjs.send(
|
||||||
config.emailJs.serviceId,
|
config.emailJs.serviceId,
|
||||||
config.emailJs.templateIdAdmin,
|
config.emailJs.templateIdAdmin,
|
||||||
templateParams,
|
templateParams,
|
||||||
{ publicKey: config.emailJs.publicKey }
|
{ publicKey: config.emailJs.publicKey }
|
||||||
),
|
);
|
||||||
|
|
||||||
// Send Auto-reply to User
|
// Send Auto-reply to User
|
||||||
emailjs.send(
|
await emailjs.send(
|
||||||
config.emailJs.serviceId,
|
config.emailJs.serviceId,
|
||||||
config.emailJs.templateIdUser,
|
config.emailJs.templateIdUser,
|
||||||
templateParams,
|
templateParams,
|
||||||
{ publicKey: config.emailJs.publicKey }
|
{ publicKey: config.emailJs.publicKey }
|
||||||
),
|
);
|
||||||
]);
|
|
||||||
|
|
||||||
setSubmitStatus('success');
|
setSubmitStatus('success');
|
||||||
setFormData({ name: '', email: '', subject: '', message: '' });
|
setFormData({ name: '', email: '', subject: '', message: '' });
|
||||||
} catch {
|
} catch (error) {
|
||||||
|
console.error('EmailJS Error:', error);
|
||||||
setSubmitStatus('error');
|
setSubmitStatus('error');
|
||||||
} finally {
|
} finally {
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ describe('Contact Page', () => {
|
|||||||
email: 'john@example.com',
|
email: 'john@example.com',
|
||||||
title: 'Test Subject',
|
title: 'Test Subject',
|
||||||
message: 'Hello world',
|
message: 'Hello world',
|
||||||
|
reply_to: 'john@example.com',
|
||||||
};
|
};
|
||||||
|
|
||||||
const expectedOptions = {
|
const expectedOptions = {
|
||||||
|
|||||||
Reference in New Issue
Block a user