• Stars
    star
    559
  • Rank 79,673 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 13 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

send mail without setting up a SMTP server

npm downloads npm-issues js-standard-style

node-sendmail

Send mail without SMTP server

If you're interested in helping out this repo, please check out the roadmap below to see if anything interests you

Roadmap

  • Add Testing
  • Add Better Error Handling
  • Add A Retry feature
  • Update how we do options
  • Respond with documented status codes
  • CRLF
  • replyTo
  • returnTo
  • Please submit your ideas as PR's

Install

npm install sendmail --save
# or
yarn add sendmail

Options

const sendmail = require('sendmail')({
  logger: {
    debug: console.log,
    info: console.info,
    warn: console.warn,
    error: console.error
  },
  silent: false,
  dkim: { // Default: False
    privateKey: fs.readFileSync('./dkim-private.pem', 'utf8'),
    keySelector: 'mydomainkey'
  },
  devPort: 1025, // Default: False
  devHost: 'localhost', // Default: localhost
  smtpPort: 2525, // Default: 25
  smtpHost: 'localhost' // Default: -1 - extra smtp host after resolveMX
})

Usage

const sendmail = require('sendmail')();

sendmail({
    from: '[email protected]',
    to: '[email protected], [email protected], [email protected] ',
    subject: 'test sendmail',
    html: 'Mail of test sendmail ',
  }, function(err, reply) {
    console.log(err && err.stack);
    console.dir(reply);
});

Examples

Please checkout our great examples

Upgrading

Note if you were on any previous version before <1.0.0 You will need to start using html instead of content. Instead of creating emails ourselves anymore we have decided to use mailcomposer to compose our emails. Which means we can give you the same great package with the best mail composer package out there.

In 1.2.0 "Converted to ES2015" which will break node 4.x

Mail Options

Note we use mailcomposer to compose our mail before we send it out so all mail options will be well documented Here. But for those who want something particular go ahead and search down below.

E-mail message fields

Below are a list of the most used options for email fields. Please read the entire list of options here Here:

  • from
  • sender
  • to
  • cc
  • bcc
  • replyTo
  • inReplyTo
  • subject
  • text
  • html

Attachments

You are also able to send attachents. Please review the list of properties here Here

Alternatives

In addition to text and HTML, any kind of data can be inserted as an alternative content of the main body. Please check that out Here

Address Formatting

All e-mail addresses can be formatted. Please check that out Here

SMTP envelope

SMTP envelope is usually auto generated from from, to, cc and bcc fields but you can change them Here

Using Embedded Images

Attachments can be used as embedded images in the HTML body. To use this feature, you need to set additional properties Here

Change Log

1.0.0 Mail Composer

  • A better way to compose the emails while still sending them out in the exact same way.

1.1.0 Support for development SMTP

  • A property describing a port for a local SMTP server (see MailHog) was added. If the property is omitted, sendmail behaves like it used to. This feature makes it possible to test an application offline and for multiple email addresses without needing to create hundreds of mail accounts. - Special thanks goes out to gumannp for PR 21

1.1.0 Add DKIM signing

  • Added a dkim object to options that can have two properties: privateKey and keySelector. These options correspond to the options for dkim-signer. Added an example for these options. Special thanks goes out to download13 for PR 23

1.1.1 Readme fix

  • simple link and text updates

1.2.0 Added Support for devHost & devPort

  • Add option to override "localhost" when sending all SMTP traffic to a dummy server & "Converted to ES2015"

1.3.0

  • Add option to override "smtpPort:25"

1.4.0

  • Add option to add extra smtp host after resolveMX "smtpHost:-1"
  • Added Yarn Lock

1.4.1

  • Update Readme

1.5.0

  • Update Readme - Special thanks goes out to zzzgit for PR 58
  • sort mx records by priority (lowest first) - Special thanks goes out to seasick for PR 57

1.6.0

  • Updated parsing to use auto parse

1.6.1

  • Rollback of autoparse

Questions, Comments & Concerns

Please reach out to Green Pioneer. If I dont respond the first time please feel free to reach out again to get help( Also try using @greenpioneer in issues or prs). Guileen is the original creator.

More Repositories

1

terminal-status

Atom terminal status
CoffeeScript
65
star
2

vim-node-dict

node.js dict for vim
Shell
43
star
3

stormjs

compile js to high performance non-blocking js
JavaScript
28
star
4

react-forum

A forum base on React.
JavaScript
22
star
5

node-mongodb-provider

Nodejs mongodb base provider class
JavaScript
16
star
6

node-forum

powered by coffee-script, mongodb, mongoskin, express, jade, stylus, 52framework
CoffeeScript
15
star
7

project-switcher

Atom plugin to switch between projects
CoffeeScript
12
star
8

node-lua

node lua binding
C++
10
star
9

eee-stat

易经
JavaScript
10
star
10

node-rts

Redis time series data store
JavaScript
9
star
11

connect-block

Best browser compatible solutioin
JavaScript
9
star
12

nothing

No downward compatibility, nearly nothing.
JavaScript
7
star
13

node-master

Cluster helper
JavaScript
7
star
14

config

my linux configuration
Vim Script
6
star
15

c10m-test

C10m test demo
Go
6
star
16

smooth.js

Smooth, throttle, queue async function parallel execution with a limitation.
JavaScript
6
star
17

guileen.github.com

My Blog
HTML
5
star
18

node-kickstart

A node.js web server example without any web framework
JavaScript
5
star
19

knockout

image knockout web app
JavaScript
5
star
20

ajaxform.js

pure javascript ajax form submission
JavaScript
5
star
21

alipay-verify

Verify the damn alipay notification with RSA
JavaScript
4
star
22

node-shorten

unique shorten ID generator by redis
JavaScript
4
star
23

slippers

Concept project of asynchronous syntactic sugar
JavaScript
4
star
24

keyboard-hacking

XKB generator by python
Python
4
star
25

mkd2slide

markdown to slide pdf
JavaScript
3
star
26

chop

chop
JavaScript
3
star
27

easysns

博览网课程源码
JavaScript
3
star
28

balancebot

HTML
2
star
29

node-cci

A very simple CI server
JavaScript
2
star
30

wow-jpack

Lua
2
star
31

node-fifo-cache

A high performance FIFO cache module with ES6 Map.
JavaScript
2
star
32

slopeone.js

slopeone.js
JavaScript
2
star
33

pitaya

Simple framework for both RESTful API and binary API
JavaScript
2
star
34

node-buffer.io

Read write binary data with buffer
JavaScript
2
star
35

node-consistent-hash

consistent hash algorithms for nodejs
JavaScript
2
star
36

asyncthrottle

Throttle for async functions, use for benchmark
JavaScript
1
star
37

node-sudoku

sudoku algorithms in coffee script
JavaScript
1
star
38

redisviewer

View redis data in web
JavaScript
1
star
39

nd101

Udacity nd101 Deep Learning course note.
Jupyter Notebook
1
star
40

leenlee

a forum by guileen and shaunlee
JavaScript
1
star
41

setupserver

scripts to setup a base server
Shell
1
star
42

posts

JavaScript
1
star
43

mem-redis

High performance cache layer. `mem[key] || redis.get(key)`
1
star
44

rts-server

Server for node-rts
JavaScript
1
star
45

kick-redis

a very simple redis session middleware
1
star
46

RiseOfLosers

JavaScript
1
star
47

node-eagle

A Realtime Connection Lib for Node.JS with API support, based on Socket.IO
JavaScript
1
star
48

hello-live

Hello world of RTC
1
star
49

redismodel

A model framework for redis.
JavaScript
1
star
50

dash5.js

A neat freak version utility library like lodash(underscore)
JavaScript
1
star
51

btree-editor

1
star
52

protocol-template

tool to generate protocol for different languages
JavaScript
1
star
53

realboy

mirror of https://sourceforge.net/projects/realboy/ see https://realboyemulator.wordpress.com/posts/
C
1
star