Sign inSign up

kindleear/mailfix

By kindleear

Updated about 2 years ago

Accept inbound email on your domain and post it to an HTTP webhook

Image
Web servers
0

433

kindleear/mailfix repository overview

Mailfix

Inspired by https://github.com/thingless/mailglove.
Docker image: https://hub.docker.com/r/thingless/mailglove

But this is very smaller, 10.72 MB vs 124.09 MB.
The Dockerfile and script can be found in Github Repository.

Feature

Accept inbound email on your domain and post it to an HTTP webhook.

Usage

docker run -p 25:25 -e DOMAIN=mail.example.com -e URL=https://example.com/mail kindleear/mailfix

DOMAIN is the domain you would like to receive email for. Your should add an A or MX record to your DNS pointing to the server you're running the docker container on.
URL is the url to post the parsed email to.

The email is posted to the webhook using orignal binary data.

#python flask example to parse email data.
import email
from flask import request
msg = email.message_from_bytes(request.get_data())
sender = msg.get('From')
to = msg.get_all('To')
subject = msg.get('Subject')
for part in msg.walk():
        cType = part.get_content_type()
        body = part.get_payload(decode=True)
        if part.get('Content-Disposition') == 'attachment':
            print(part.get_filename(), body))
        elif cType == 'text/plain':
            print(body.decode(part.get_content_charset('us-ascii')))
        elif cType == 'text/html':
            print(body.decode(part.get_content_charset('us-ascii')))

Tag summary

Content type

Image

Digest

sha256:b152be6e7

Size

10.7 MB

Last updated

about 2 years ago

docker pull kindleear/mailfix