smtp-mailer
v1.0.0
Published
Mailazy NodeJs SDK Client
Downloads
14
Maintainers
Readme
NodeJS SMTP Email API SDK
Mailazy NodeJs SDK Client
Table of Contents
Install
Prerequisites
- Node.js version >= 10
- Mailazy account, sign up for free.
Generate Access Keys
You need a sender/domain authenticated account in order to generate Access Keys from the Mailazy Console
Install Package
npm:
npm install smtp-mailer
yarn:
yarn add smtp-mailer
Usage
Email API
const MailazyClient = require('smtp-mailer');
const client = new MailazyClient({
serviceType: "API", //SMTP,API
auth: {
user: '___mailazy_access_key___',
pass: '___mailazy_access_secret___'
}
});
const fn = async () => {
try {
const resp = await client.send({
from: "[email protected]", // required, Use domain you verified
to: "[email protected]", // required, user comma (,) for multiple recipients
cc: "[email protected]", // optional, user comma (,) for multiple recipients
bcc: "[email protected]", // optional, user comma (,) for multiple recipients
reply_to: "[email protected]", // optional
subject: 'test email from node.js app with attachment', // required
text: 'hello world!', // required
html: '<b>hello world</b>', // required
attachments: [ // optional
{
filename: 'hello.csv',
path: path.join(__dirname, `hello.csv`),
contentType: 'application/octet-stream'
}
]
});
console.log('resp: ' + resp);
} catch (e) {
console.log('error: ' + e);
}
};
fn();
SMTP
const MailazyClient = require('smtp-mailer');
const client = new MailazyClient({
serviceType: "SMTP", //SMTP,API
auth: {
user: '___mailazy_access_key___',
pass: '___mailazy_access_secret___'
}
});
const fn = async () => {
try {
const resp = await client.send({
from: "[email protected]", // required, Use domain you verified
to: "[email protected]", // required, user comma (,) for multiple recipients
cc: "[email protected]", // optional, user comma (,) for multiple recipients
bcc: "[email protected]", // optional, user comma (,) for multiple recipients
reply_to: "[email protected]", // optional
subject: 'test email from node.js app with attachment', // required
text: 'hello world!', // required
html: '<b>hello world</b>', // required
attachments: [ // optional
{
filename: 'hello.csv',
path: path.join(__dirname, `hello.csv`),
contentType: 'application/octet-stream'
}
]
});
console.log('resp: ' + resp);
} catch (e) {
console.log('error: ' + e);
}
};
fn();
License
MIT © Mailazy