Coder Social home page Coder Social logo

directmail's Introduction

DirectMail

Sendmail alternative to send e-mails directly to recipients without a relaying service.

Support DirectMail development

Donate to author

If you want to support with Bitcoins then my wallet address is 15Z8ADxhssKUiwP3jbbqJwA21744KMCfTM

Usage

Setup

Require directmail object

var createDirectmail = require("directmail"),
    directmail = createDirectmail(options);

Where

  • options is an optional options object with the following properties
    • debug - if set to true, prints all traffic to console
    • name - hostname to be used when introducing the client to the MX server

Send mail

Push a message to the outgoing queue

directmail.send({
    from: "[email protected]",
    recipients: ["[email protected]", "[email protected]"],
    message: "Subject: test\r\n\r\nHello world!"
});

Where

  • from (string) is the e-mail address of the sender
  • recipients (array) is an array of recipient e-mails. Put all to, cc and bcc addresses here.
  • message (string|buffer) is the RFC2822 message to be sent

Check queue length

You can check the count of unsent messages from the .length property of the directmail object

console.log(directmail.length); // nr of messages to be sent

If you try to send a message with multiple recipients then every unique recipient domain counts as a different message.

Issues

Directmail is very inefficient as it queues all e-mails to be sent into memory. Additionally, if a message is not yet sent and the process is closed, all data about queued messages are lost. Thus directmail is only suitable for low throughput systems, like password remainders and such, where the message can be processed immediatelly. Directmail is not suitable for spamming.

While not being 100% reliable (remember - if process exits, entire queue is lost), directmail can still handle sending errors, graylisting and such. If a message can not be sent, it is requeued and retried later.

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.