Skip to content

W84Soft/node-sendmail

 
 

Repository files navigation

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 i https://github.com/W84Soft/node-sendmail
# or
npm i github:W84Soft/node-sendmail

Options

import sendMailFactory from "sendmail";

const sendmail = sendMailFactory({
	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

import sendMailFactory from "sendmail";
const sendmail=sendMailFactory();

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

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

About

send mail without setting up a SMTP server

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%