Git Product home page Git Product logo

mail-receiver's Introduction

A simple delivery smtp server to assist in development and testing of software that requires email accounts (i.e. identity management). There's no accounts to manage. All emails will be saved to file. You can therefore use a different email "account" for every automated test run for example.

This is mostly just configuration around the excellent Nodemailer SMTP Server plus some file saving.

Warning: Not secure. Nothing is encrypted.

Requirements

  • A server running Node.js 16+ that's reacheable via public internet
  • A domain name and access to its DNS configuration

Setup

Let's assume that you want to receive emails sent to the @dev1.mail.example.com and @dev2.mail.example.com domains.

DNS

You will need 3 DNS records:

mydevserver.example.com   A    <ip of your server>
dev1.mail.example.com     MX   10   mydevserver.example.com
dev2.mail.example.com     MX   10   mydevserver.example.com 

System Configuration

SMTP delivery runs on port 25. On Linux, only root can bind to this port. Running node as root is bad. You can override the limitation for the node binary with a command such as this:

sudo setcap CAP_NET_BIND_SERVICE=+eip /home/myuser/.nvm/versions/node/v16.15.1/bin/node

App Configuration

After cloning this repo, inside the project directory:

1. Create a .env file that looks like this

API_KEY=averylongpasswordtoprotectadminapi
EMAIL_DOMAINS=dev1.mail.example.com,dev2.mail.example.com
EMAIL_ACCOUNT_PREFIX=goodmailonly-
ADMIN_APP_PORT=2255

Emails sent to addresses that don't start with the prefix will be ignored. This provides some crude protection against spam. In the above example, an email sent to [email protected] will be saved to file. An email sent to [email protected] will be rejected.

2. Run npm i

3. Run npm start

Emails will be saved in the mail folder

API Access

You can get a list of all received emails by week using the admin api: /api/mail/<year>/<week-number>?api_key=<configured setting>. The weekly view provides API links to examine individual messages.

Testing your setup / Sending Email

Testing this tool by using the SMTP protocol to directly call port 25 can be tricky since many ISPs and service providers (e.g. AWS) block outgoing traffic on port 25. Therefore, you'll need a proper SMTP gateway to send messages. You cand easily test your setup by manually sending emails from say gmail.

mail-receiver's People

Contributors

marrrrko avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

darktohka

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.