@thermopylae/lib.email
v1.0.1
Published
Email client.
Downloads
2
Maintainers
Readme
Email client.
Install
npm install @thermopylae/lib.email
Description
This package contains EmailClient which can send emails. In order to accomplish this task, it uses internally nodemailer npm package.
Usage
import { EmailClient } from '@thermopylae/lib.email';
(async function main() {
const emailClient = new EmailClient({
transport: {
options: {
service: 'gmail',
auth: {
type: 'OAuth2',
user: '[email protected]',
clientId: 'CLIENT-ID',
clientSecret: 'CLIENT-SECRET',
refreshToken: 'REFRESH-TOKEN',
accessToken: 'ACCESS-TOKEN'
}
},
defaults: {
from: '[email protected]'
}
},
hooks: {
onTransportError(err) {
console.error('Error encountered in email transport: ', err);
},
onTransportIdle() {
console.info('Email transport is idle.');
}
}
});
const sentEmailInfo = await emailClient.send({
to: ['[email protected]'],
subject: 'Demo Email',
text: 'Demo text'
});
console.log('Email has been sent. Details: ', JSON.stringify(sentEmailInfo));
emailClient.close();
})();
API Reference
API documentation is available here.
It can also be generated by issuing the following commands:
git clone [email protected]:marinrusu1997/thermopylae.git
cd thermopylae
yarn install
yarn workspace @thermopylae/lib.email run doc
Author
👤 Rusu Marin
- GitHub: @marinrusu1997
- Email: [email protected]
- LinkedIn: @marinrusu1997
📝 License
Copyright © 2021 Rusu Marin. This project is MIT licensed.