Skip to content

Commit d79fb71

Browse files
author
Sachin Maheshwari
committed
adding 'replyTo' support.
1 parent 46ad0de commit d79fb71

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

connect/connectEmailServer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ const handler = (topic, message, callback) => {
2626
return callback(null, { success: false, error: `Template not found for topic ${topic}` });
2727
}
2828

29-
service.sendEmail(templateId, message.recipients, message.data).then(() => {
29+
const replyTo = message.replyTo ? message.replyTo : config.EMAIL_FROM;
30+
service.sendEmail(templateId, message.recipients, message.data, replyTo).then(() => {
3031
callback(null, { success: true });
3132
}).catch((err) => {
3233
callback(null, { success: false, error: err });

connect/service.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ const config = require('config');
99
// set api key for SendGrid email client
1010
sgMail.setApiKey(config.SENDGRID_API_KEY);
1111

12-
const sendEmail = (templateId, to, substitutions) => // send email
12+
const sendEmail = (templateId, to, substitutions, replyTo) => // send email
1313
sgMail.send({
1414
to,
1515
templateId,
1616
substitutions,
1717
from: config.EMAIL_FROM,
1818
substitutionWrappers: ['{{', '}}'],
19+
replyTo,
1920
});
2021

2122
module.exports = {

test/emailServiceTest.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const defaultHandler = (topic, message, callback) => {
2424
}
2525

2626
// send email
27+
const replyTo = message.replyTo ? message.replyTo : config.EMAIL_FROM;
2728
service.sendEmail(templateId, message.recipients, message.data).then(() => {
2829
callback(null, { success: true });
2930
finish(null);

0 commit comments

Comments
 (0)