Skip to content

Commit

Permalink
feat: add email sender functionality with smtp host and port from config
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieSlome committed Feb 9, 2024
1 parent b3b5fa8 commit 0858219
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/service/emailSender.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const nodemailer = require('nodemailer');
const config = require('../config');

exports.sendEmail = async (from, to, subject, body) => {
const smtpHost = config.getSmtpHost();
const smtpPort = config.getSmtpPort();
const transporter = nodemailer.createTransport({

Check warning on line 7 in src/service/emailSender.js

View check run for this annotation

Codecov / codecov/patch

src/service/emailSender.js#L5-L7

Added lines #L5 - L7 were not covered by tests
host: smtpHost,
port: smtpPort,
});

const email = `${body}`;
const info = await transporter.sendMail({

Check warning on line 13 in src/service/emailSender.js

View check run for this annotation

Codecov / codecov/patch

src/service/emailSender.js#L12-L13

Added lines #L12 - L13 were not covered by tests
from,
to,
subject,
html: email,
});
console.log('Message sent %s', info.messageId);

Check warning on line 19 in src/service/emailSender.js

View check run for this annotation

Codecov / codecov/patch

src/service/emailSender.js#L19

Added line #L19 was not covered by tests
};

0 comments on commit 0858219

Please sign in to comment.