Giter Site home page Giter Site logo

deysuman / smtp-listener Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 9 KB

A NodeJS script that acts as a SMTP listen server. Accepts all emails, and emits them both as an EventEmitter and through a socket.

License: Apache License 2.0

JavaScript 100.00%
nodejs smtp-server smtp smtp-mail smtp-client smtp-library smtp-listerner listener mail socket socket-programming

smtp-listener's Introduction

smtp-listener

A NodeJS script that acts as a SMTP listen server. Accepts all emails, and emits them both as an EventEmitter and through a socket.

suman made-with-nodejs

Usage (single access)

If only 1 script needs to receive mails:

const SMTPServer = require("smtp-listener").Server;
const server = new SMTPServer(25 /* port */);
server.on("[email protected]", (mail)=>{
    ...
});

Usage (multi access)

If multiple scripts need to receive mails, create a symlink at /var/dev/smtp-listener/ pointing to the working directory, then create a symlink at /etc/systemd/system/smtp-listener.service pointing to ./service/smtp-listener.service. Finally run sudo systemctl start smtp-listener. This starts the server and keeps it running should it crash.

If you aren't running systemd, do the equivalent on your system.

Then in your scripts do

const SMTPClient = require("smtp-listener");
const client = new SMTPClient();
client.on("[email protected]", ()=>{
    ...
});

Mail object

All listeners receive a single response, a Mail object. This is simply the email parsed by Nodemailer's Mailparser. See their documentation for details.

Socket

If you need access to mails from non-JS code (or you don't want to use SMTPClient), you can instead listen to the UNIX/Windows socket (default UNIX location: /tmp/app.smtp-listener).

The server emits emails as UTF8-encoded JSON to all clients, using node-ipc.

smtp-listener's People

Contributors

deysuman avatar

Watchers

 avatar  avatar

Forkers

ebackup233

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.