-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |