msztolcman / sendria

Sendria (formerly MailTrap) is a SMTP server designed to run in your dev/test environment, that is designed to catch any email you or your application is sending, and display it in a web interface instead of sending to real world.
MIT License
147 stars 14 forks source link
developer-tools email mail mailcatcher mailcatcher-alternative maildump maildump-alternative mailtrap mta-server smtp smtp-server

Sendria

sendria version sendria license sendria python compatibility Downloads say thanks!

Sendria (formerly MailTrap) is a SMTP server designed to run in your dev/test environment, catch any email you or your application is sending, and display it in a web interface instead of sending to real world. It help you prevent sending any dev/test emails to real people, no matter what address you provide. Just point your app/email client to smtp://127.0.0.1:1025 and look at your emails on http://127.0.0.1:1080.

Sendria is built on shoulders of:

If you like this tool, just say thanks.

Icon made by Freepik from www.flaticon.com.

Current stable version

2.2.2

Features

Installation

Sendria should work on any POSIX platform where Python is available, it means Linux, MacOS/OSX etc.

Simplest way is to use Python's built-in package system:

python3 -m pip install sendria

You can also use pipx if you don't want to mess with system packages and install Sendria in virtual environment:

pipx install sendria

Voila!

Python version

Sendria is tested against Python 3.7+. Older Python versions may work, or may not.

If you want to run this software on Python 2.6+, just use MailDump.

How to use

After installing Sendria just run command:

sendria --db mails.sqlite

Now send emails through smtp://127.0.0.1:1025, i.e.:

echo 'From: Sendria <sendria@example.com>\n'\
'To: You <you@example.com>\n'\
'Subject: Welcome!\n\n'\
'Welcome to Sendria!' | \
  curl smtp://localhost:1025 --mail-from sendria@example.com \
    --mail-rcpt you@example.com --upload-file -

or simpler with SMTPc:

smtpc send --host localhost:1025 --from sendria@example.com --to you@example.com \
  --subject 'Welcome!' --body 'Welcome to Sendria!'

Finally, look at Sendria GUI on 127.0.0.1:1080.

If you want more details, run:

sendria --help

for more info, ie. how to protect access to gui.

API

Sendria offers RESTful API you can use to fetch list of messages or particular message, ie. for testing purposes.

You can use excellent httpie tool:

% http localhost:1080/api/messages/
HTTP/1.1 200 OK
Content-Length: 620
Content-Type: application/json; charset=utf-8
Date: Wed, 22 Jul 2020 20:04:46 GMT
Server: Sendria/2.2.2 (https://sendria.net)

{
    "code": "OK",
    "data": [
        {
            "created_at": "2020-07-22T20:04:41",
            "id": 1,
            "peer": "127.0.0.1:59872",
            "recipients_envelope": [
                "you@example.com"
            ],
            "recipients_message_bcc": [],
            "recipients_message_cc": [],
            "recipients_message_to": [
                "You <you@exampl.com>"
            ],
            "sender_envelope": "sendria@example.com",
            "sender_message": "Sendria <sendria@example.com>",
            "size": 191,
            "source": "From: Sendria <sendria@example.com>\nTo: You <you@exampl.com>\nSubject: Welcome!\nX-Peer: ('127.0.0.1', 59872)\nX-MailFrom: sendria@example.com\nX-RcptTo: you@example.com\n\nWelcome to Sendria!\n",
            "subject": "Welcome!",
            "type": "text/plain"
        }
    ],
    "meta": {
        "pages_total": 3
    }
}

There are available endpoints:

Docker

There is also available Docker image of Sendria. If you want to try, just run:

docker run -p 1025:1025 -p 1080:1080 msztolcman/sendria

Help!

I'm backend developer, not a frontend guy nor designer... If you are, and want to help, just mail me!. I think GUI should be redesigned, or at least few minor issues could be solved. Also, project requires some logo and/or icon. Again, do not hesitate to mail me if you want and can help :)

Also, if you have an idea how to enhance Sendria, please fill the ticket. Every idea, every feature request can help you, me and others!

Configure Rails

For your rails application just set in your environments/development.rb:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { :address => '127.0.0.1', :port => 1025 }
config.action_mailer.raise_delivery_errors = false

Configure Django

To configure Django to work with Sendria, add the following to your projects' settings.py:

if DEBUG:
    EMAIL_HOST = '127.0.0.1'
    EMAIL_HOST_USER = ''
    EMAIL_HOST_PASSWORD = ''
    EMAIL_PORT = 1025
    EMAIL_USE_TLS = False

Configure Laravel

To use Sendria in a Laravel project, configure your .env file as follow:

MAIL_DRIVER=smtp
MAIL_HOST=127.0.0.1
MAIL_PORT=1025
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tcp
MAIL_FROM_ADDRESS=your@domain.com

As Sendria does not support TLS or SSL, it's very important to specify MAIL_ENCRYPTION=tcp (instead of the default MAIL_ENCRYPTION=null), otherwise you will get a Swift_TransportException (with error stream_socket_client(): unable to connect to null://127.0.0.1).

Behind nginx

If you want to hide Sendria behind nginx (ie. to terminate ssl) then you can use example config (see in addons).

Supervisord

To start Sendria automatically with Supervisor there is in addons example config file for this purpose.

Authors

Contact

If you like or dislike this software, please do not hesitate to tell me about this me via email (marcin@urzenia.net).

If you find bug or have an idea to enhance this tool, please use GitHub's issues.

ChangeLog

v2.3.0

v2.2.2

v2.2.1

v.2.2.0

v2.1.0

v2.0.1

v2.0.0

v1.0.0

Backward incompatible changes:

v0.1.6

v0.1.4

v0.1.3

v0.1.2

v0.1.0