![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
nodemailer-smtp-transport
Advanced tools
Applies for Nodemailer v1.x and not for v0.x where transports are built-in.
Install with npm
npm install nodemailer-smtp-transport
Require to your script
var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport');
Create a Nodemailer transport object
var transporter = nodemailer.createTransport(smtpTransport(options))
or (by using smtpTransport as default)
var transporter = nodemailer.createTransport(options)
Where
true
) or not (if false
)Example
var transport = nodemailer.createTransport(smtpTransport({
host: 'localhost',
port: 25,
auth: {
user: 'username',
pass: 'password'
}
}));
If authentication data is not present, the connection is considered authenticated from the start.
Set authentcation data with options.auth
Where
pass
and xoauth2
values are set) or an XOAuth2 token generator object.If a XOAuth2 token generator is used as the value for auth.xoauth2
then you do not need to set the value for auth.user
. XOAuth2 generator generates required accessToken
itself if it is missing or expired. In this case if the authentication fails, a new token is requested and the authentication is retried once. If it still fails, an error is returned.
Install xoauth2 module to use XOauth2 token generators (not included by default)
npm install xoauth2 --save
XOAuth2 Example
NB! The correct OAuth2 scope for Gmail is
https://mail.google.com/
var nodemailer = require('nodemailer');
var generator = require('xoauth2').createXOAuth2Generator({
user: '{username}',
clientId: '{Client ID}',
clientSecret: '{Client Secret}',
refreshToken: '{refresh-token}',
accessToken: '{cached access token}' // optional
});
// listen for token updates
// you probably want to store these to a db
generator.on('token', function(token){
console.log('New token for %s: %s', token.user, token.accessToken);
});
// login
var transporter = nodemailer.createTransport(({
service: 'gmail',
auth: {
xoauth2: generator
}
}));
// send mail
transporter.sendMail({
from: 'sender@example.com',
to: 'receiver@example.com',
subject: 'hello world!',
text: 'Authenticated with OAuth2'
});
If you do not want to specify the hostname, port and security settings for a well known service, you can use it by its name (case insensitive)
smtpTransport({
service: 'gmail',
auth: ..
});
See the list of all supported services here.
MIT
FAQs
SMTP transport for Nodemailer
The npm package nodemailer-smtp-transport receives a total of 0 weekly downloads. As such, nodemailer-smtp-transport popularity was classified as not popular.
We found that nodemailer-smtp-transport demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.