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

@anxolin/mail

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@anxolin/mail

Simple mail repository

  • 0.1.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

node-mail

Basic mail sender

Implement a repository for easily sending mails. It uses nodemailer and all methods return promises.

Usage

First install dependencies:

yarn add @anxolin/mail --save # npm install @anxolin/mail --save

Then, use it:

const mailSender = require('@anxolin/mail')({
  user: 'your-user',
  password: 'your-password',
  host: 'your-password'
})

// Verify the connection
mailSender
  .verify()
  .then(success => console.log('Mail connection result: %s', success))
  .catch(console.error)

mailSender
  .sendMail({
    from: 'foo@example.com',
    to: 'baz@example.com',
    subject: 'Hi there ✔',
    text: 'How are you doing?',
    html: 'How are <b>you</b> doing?'
  })
  .then(mailInfo => console.log('Mail sent: %s', mailInfo.messageId))
  .catch(console.error)

Config

const mailSender = require('@anxolin/mail')(config)

Where config may contain:

ParameterRequiredDescription
userYesUser for the mail authentication
passwordYesPassword for the mail authentication
hostYesMail server host
portNo. Default 587Port
secureNo. Default falseSecure
requireTLSNo. Dedault trueRequire TLS

Send a test mail

To test, execute:

yarn install

# Execute
MAIL_USER=foo@example.com \
MAIL_PASSWORD=your-pass-here \
HOST=mail.example.com \
FROM=foo@example.com \
TO=baz@example.com \
SUBJECT="Hi there ✔" \
TEXT="How are you doing?" \
HTML="How are <b>you</b> doing?" \
yarn send-mail

Create a .env file

A simpler approach to execute the mail sender is to create a .env file:

MAIL_USER=foo@example.com
MAIL_PASSWORD=your-pass-here
HOST=mail.example.com
FROM=foo@example.com
TO=baz@example.com
SUBJECT="Hi there ✔"
TEXT="How are you doing?"
HTML="How are <b>you</b> doing?"
yarn send-mail

Execute the tests

yarn test

FAQs

Package last updated on 27 Jun 2018

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