Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nodemailer-smtp-transport

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodemailer-smtp-transport

SMTP transport for Nodemailer

  • 2.7.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
119K
decreased by-16.65%
Maintainers
1
Weekly downloads
 
Created

What is nodemailer-smtp-transport?

The nodemailer-smtp-transport package is a transport module for Nodemailer that allows you to send emails using the SMTP protocol. It provides a way to configure and use SMTP servers to send emails programmatically.

What are nodemailer-smtp-transport's main functionalities?

Basic SMTP Transport Configuration

This code demonstrates how to configure and use the nodemailer-smtp-transport package to send an email using an SMTP server. It sets up the SMTP transport with the necessary authentication details and sends an email with both text and HTML content.

const nodemailer = require('nodemailer');
const smtpTransport = require('nodemailer-smtp-transport');

const transporter = nodemailer.createTransport(smtpTransport({
  host: 'smtp.example.com',
  port: 587,
  secure: false, // true for 465, false for other ports
  auth: {
    user: 'username',
    pass: 'password'
  }
}));

const mailOptions = {
  from: 'sender@example.com',
  to: 'receiver@example.com',
  subject: 'Hello',
  text: 'Hello world',
  html: '<b>Hello world</b>'
};

transporter.sendMail(mailOptions, (error, info) => {
  if (error) {
    return console.log(error);
  }
  console.log('Message sent: %s', info.messageId);
});

Using OAuth2 for Authentication

This code demonstrates how to use OAuth2 for authentication with the nodemailer-smtp-transport package. It configures the transport with OAuth2 credentials and sends an email using Gmail's SMTP server.

const nodemailer = require('nodemailer');
const smtpTransport = require('nodemailer-smtp-transport');

const transporter = nodemailer.createTransport(smtpTransport({
  service: 'gmail',
  auth: {
    type: 'OAuth2',
    user: 'user@example.com',
    clientId: 'your-client-id',
    clientSecret: 'your-client-secret',
    refreshToken: 'your-refresh-token',
    accessToken: 'your-access-token'
  }
}));

const mailOptions = {
  from: 'sender@example.com',
  to: 'receiver@example.com',
  subject: 'Hello',
  text: 'Hello world',
  html: '<b>Hello world</b>'
};

transporter.sendMail(mailOptions, (error, info) => {
  if (error) {
    return console.log(error);
  }
  console.log('Message sent: %s', info.messageId);
});

Other packages similar to nodemailer-smtp-transport

Keywords

FAQs

Package last updated on 05 Sep 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc