Skip to content

Commit

Permalink
Updated examples
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Jan 21, 2023
1 parent 072e1aa commit 01840df
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/await.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function main() {
// default message fields

// sender info
from: 'Pangalink <no-reply@pangalink.net>',
from: `<${account.user}>`,
headers: {
'X-Laziness-level': 1000 // just an example header, no need to use this
}
Expand All @@ -40,7 +40,7 @@ async function main() {
// Message object
let message = {
// Comma separated list of recipients
to: 'Andris Reinman <andris.reinman@gmail.com>',
to: 'Andris Reinman <andris@ethereal.email>',

// Subject of the message
subject: 'Nodemailer is unicode friendly ✔',
Expand Down
42 changes: 42 additions & 0 deletions examples/verify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* eslint no-console: 0 */

'use strict';

const nodemailer = require('../lib/nodemailer');

async function main() {
// Generate SMTP service account from ethereal.email
let account = await nodemailer.createTestAccount();

console.log('Verifying obtained credentials...');

// NB! Store the account object values somewhere if you want
// to re-use the same account for future mail deliveries

// Create a SMTP transporter object
let transporter = nodemailer.createTransport({
host: account.smtp.host,
port: account.smtp.port,
secure: account.smtp.secure,
auth: {
user: account.user,
pass: account.pass
},
logger: false,
debug: false // include SMTP traffic in the logs
});

try {
await transporter.verify();
console.log('Credentials are valid');
} catch (err) {
// throws on invalid credentials
console.log('Credentials are invalid');
throw err;
}
}

main().catch(err => {
console.error(err.message);
process.exit(1);
});

0 comments on commit 01840df

Please sign in to comment.