Skip to content

Email relay service with SMTP server that validates recipients via callback URLs before delivery, eliminating spam at the source.

Notifications You must be signed in to change notification settings

devZenta/SafeSend

Repository files navigation

SafeSend

SafeSend is a tiny project to make a proof of concept of a simple but amazing idea: annihilate spam, for ever.

Development

You will need to have a local maildev server running. To do so, run:

docker run -p 1080:1080 -p 1025:1025 maildev/maildev

And then, run the server locally:

# For the first time create a JWT secret
echo 'JWT_SECRET=yop' > .env.app.local
echo 'SMTP_CONNECTION_URL = smtp://localhost:1025' >> .env.app.local
# And install the dependencies 
npm it
# Update the tests
node --run jest -- -u

# Then and later, just run the server
npm run watch

Testing email knocking workflow:

# This should be rejected per domain filtering
SMTP_CONNECTION_URL=smtp://localhost:2025 node --run dev -- sendMail --recipient text@whatever.com --sender test@xmp.com --subject test --message test

# This should be rejected and send an email to ask sender to knock
SMTP_CONNECTION_URL=smtp://localhost:2025 node --run dev -- sendMail --recipient text@enigma.com --sender test@xmp.com --subject test --message test

# This should knock properly
SMTP_CONNECTION_URL=smtp://localhost:2025 node --run dev -- sendMail --recipient text+knock@enigma.com --sender test@xmp.com --subject test --message test

# This should work with the appropriate token
SMTP_CONNECTION_URL=smtp://localhost:2025 node --run dev -- sendMail --recipient text+$APPROPRIATE_TOKEN@enigma.com --sender test@xmp.com --subject test --message test

You can debug the token store anytime by running:

cat /tmp/token_store.json

Usage

To run the server in production:

# For the first time create a JWT secret
echo 'JWT_SECRET=$(openssl rand -base64 10)' > .env.app.production
# And install the dependencies 
npm it

# Then and later, just run build and run the server
npm run build
NODE_ENV=production APP_ENV=production npm start

You can understand deeply this repository and Whook's internal by simply reading the Architecture Notes. The "See in context" links drive your directly in the concerned implementation so that you can just see the code that explains the notes.

Feel free to continue creating architecture notes and to regenerate the markdown file by running:

node --run architecture

Dev

Start the server in development:

# Simple dev mode
node --run dev

# Watch mode
node --run watch

Create a new route / cron / service / provider or command:

node --run create

Play with the REPL:

node --run repl

Generate the dependency injection graph (here, for the putTime handler):

node --run  whook -- __inject putTime,mermaid > DEPENDENCIES.mmd;
docker run --rm -u `id -u`:`id -g` -v $(pwd):/data minlag/mermaid-cli --scale 4 -i DEPENDENCIES.mmd -o DEPENDENCIES.mmd.svg;

List available commands:

## In dev mode
node --run dev -- ls
## With built files
npx whook ls

Generate API types:

node --run apitypes

Debug

Execute a handler in isolation:

npx whook route --name putEcho --parameters '{"body": { "echo": "YOLO!" }}'

Debug whook internals:

DEBUG=whook node --run dev

Debug knifecycle internals (dependency injection issues):

DEBUG=knifecycle node --run dev

Author

Enigma Students

About

Email relay service with SMTP server that validates recipients via callback URLs before delivery, eliminating spam at the source.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors 8