🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

outlook-nodemailer-transport

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

outlook-nodemailer-transport

Outlook API and Nodemailer v4+. The plugin uses send scope only

latest
Source
npmnpm
Version
1.4.1
Version published
Maintainers
1
Created
Source

outlook-nodemailer-transport

Intro

The custom transport plugin that allows to send email using Nodemailer via Outlook

Why?

With the help of the Outlook API it is possible to use the send scope and Nodemailer v4+. The plugin is very small, optimized and written in TypeScript

Support the project

If you like to use this module please click the star button - it is very motivating.

Quick Start

Install outlook-nodemailer-transport using npm:

$ npm install outlook-nodemailer-transport --save

Documentation

Nodemailer common fields are supported and replyTo

Examples

send the simple email by the access token

  'use strict';
  const nodemailer = require('nodemailer');
  const OutlookTransport = require('outlook-nodemailer-transport');

  let transporter = nodemailer.createTransport(new OutlookTransport({
    userId: 'my-address@outlook.com',
    auth: {
      accessToken: 'ya29.Glv5BvE5y-access-token'
    }
  }));

  transporter.sendMail({
    from: 'email@outlook.com',
    to: 'recipient@test.com',
    replyTo: 'reply-to@example.com',
    subject: 'Outlook Transport',
    text: 'This is text content'
  }).then((info) => {
    console.log('SUCCESS');
  }).catch((error) => {
    console.log('Something is wrong');
  });

send the simple email, if it's failed to refresh the access token

  'use strict';
  const nodemailer = require('nodemailer');
  const OutlookTransport = require('outlook-nodemailer-transport');

  let transporter = nodemailer.createTransport(new OutlookTransport({
    userId: 'my-address@outlook.com',
    auth: {
      clientId: 'clien-id.apps.googleusercontent.com',
      clientSecret: 'clint-secret',
      refreshToken: '1/EAATBaMn-refresh-token',
      accessToken: 'ya29.Glv5BvE5y-access-token'
    }
  }));

  transporter.sendMail({
    from: 'email@outlook.com',
    to: 'recipient@test.com',
    replyTo: 'reply-to@example.com',
    subject: 'Outlook Transport',
    text: 'This is text content'
  }).then((info) => {
    console.log('SUCCESS');
  }).catch((error) => {
    console.log('Something is wrong');
  });

send an attachment and embed it to the content

  'use strict';
  const nodemailer = require('nodemailer');
  const OutlookTransport = require('outlook-nodemailer-transport');

  let transporter = nodemailer.createTransport(new OutlookTransport({
    userId: 'my-address@outlook.com',
    auth: {
      accessToken: 'ya29.Glv5BvE5y-access-token'
    }
  }));

  transporter.sendMail({
    from: 'email@example.com',
    to: 'recipient@test.com',
    replyTo: 'reply-to@example.com',
    subject: 'Outlook Transport',
    html: '<!DOCTYPE html><html><body><img src="cid:attachment" alt="attachment"></body></html>',
    attachments: [{
      content: '/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAA...', // base64 content
      cid: 'attachment',
      contentType: 'image/jpeg',
      filename: 'attachment.jpg',
      encoding: 'base64'
    }]
  }).then((info) => {
    console.log('SUCCESS');
  }).catch((error) => {
    console.log('Something is wrong');
  });

License

MIT

Keywords

outlook

FAQs

Package last updated on 29 Jun 2023

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