This module or docker image will:
- Spawn a SMTP Server at port 8080
- Parse the emails received there
- POST the results to given endpoint
Build docker image:
docker build -t carlosbaraza/smtp2json:latest .
Run image exposing port 8080 as 25 (requires root access) and setting the ENV variable POST_URI to the URI of your service:
sudo docker run -p 25:8080 -e POST_URI='https://yourservice.com/emails' carlosbaraza/smtp2json:latest
- Create a mockbin: http://mockbin.org/bin/create
- Start the server:
sudo docker run -p 25:8080 -e POST_URI='https://mockbin.org/bin/71c8cf5c-f6fb-4f39-a7e8-b50c8fb7410d' carlosbaraza/smtp2json:latest
- Use telnet to send a fake email:
telnet localhost 25
- Paste this fake email:
HELO localhost
MAIL FROM: <foo@foo.com>
RCPT TO: <bar@bar.com>
DATA
Subject: Test subject
To: Carlos
From: Foo
This is the body for the email.
With multiple paragraphs.
.
QUIT
- Build docker image:
docker build -t carlosbaraza/smtp2json:latest .
- Publish to docker cloud repository:
docker push carlosbaraza/smtp2json:latest
- Create docker cloud service:
privileged: true
export port 8080 as 25 (Default SMTP port)
set env variable POST_URI with the URI to the API endpoint
- Add DNS MX record pointing to Service hostname
SUBDOMAIN.YOURDOMAIN.COM. MX 0 smtp2json-12345678.12345678.svc.dockerapp.io
-
Send test email to
test@SUBDOMAIN.YOURDOMAIN.COM
-
Check logs to confirm it worked