Skip to content

Commit

Permalink
renamed MailTrap -> Sendria due to conflict with mailtrap.io
Browse files Browse the repository at this point in the history
  • Loading branch information
msztolcman committed Oct 3, 2020
1 parent 3441d3d commit c9ac80e
Show file tree
Hide file tree
Showing 59 changed files with 250 additions and 199 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
/build/
/env/
/env-*/
/mailtrap/static/assets/
/mailtrap/static/.webassets-cache/
/sendria/static/assets/
/sendria/static/.webassets-cache/
/*.sqlite
/*.htpasswd
/.venv
6 changes: 3 additions & 3 deletions .versionner.rc
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ encoding = utf-8
[file:Dockerfile]
enabled = true
match = line
search = \bpip install mailtrap==\d+\.\d+\.\d+\b
replace = pip install mailtrap==%(version)s
search = \bpip install sendria==\d+\.\d+\.\d+\b
replace = pip install sendria==%(version)s
encoding = utf-8

[file:mailtrap/__init__.py]
[file:sendria/__init__.py]
enabled = true
match = line
search = \__version__ = '[\w.-]+'
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM python:3.8-slim-buster
MAINTAINER Marcin Sztolcman <[email protected]>

RUN useradd --create-home mailtrap
WORKDIR /home/mailtrap
USER mailtrap
RUN python3 -m pip install --user mailtrap==1.0.0
RUN useradd --create-home sendria
WORKDIR /home/sendria
USER sendria
RUN python3 -m pip install --user sendria==1.0.0

EXPOSE 1025 1080

CMD ["/home/mailtrap/.local/bin/mailtrap", "--foreground", "--db=./mails.sqlite", "--smtp-ip=0.0.0.0", "--http-ip=0.0.0.0"]
CMD ["/home/sendria/.local/bin/sendria", "--foreground", "--db=./mails.sqlite", "--smtp-ip=0.0.0.0", "--http-ip=0.0.0.0"]

4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include LICENSE
graft mailtrap/templates
graft mailtrap/static
graft sendria/templates
graft sendria/static
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ distro: ## build and upload distro
clean: ## cleanup all distro
-rm -fr dist
-rm -fr __pycache__
-rm -fr mailtrap/__pycache__
-rm -fr sendria/__pycache__
-rm -fr build
-rm -fr mailtrap/static/.webassets-cache/ mailtrap/static/assets/bundle.*
-rm -fr sendria/static/.webassets-cache/ sendria/static/assets/bundle.*

build: ## build distro
webassets -m mailtrap.build_assets build
webassets -m sendria.build_assets build
python3 setup.py sdist bdist_wheel
-rm -rf mailtrap/static/.webassets-cache/ mailtrap/static/assets/bundle.*
-rm -rf sendria/static/.webassets-cache/ sendria/static/assets/bundle.*

upload: ## upload distro
twine upload dist/mailtrap*
twine upload dist/sendria*

upload-test: ## upload distro to test Pypi
twine upload --repository testpypi dist/mailtrap*
twine upload --repository testpypi dist/sendria*

.DEFAULT_GOAL := help
help:
Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ versionner = "*"
twine = "*"
wheel = "*"
colorama = "*"
mailtrap = {editable = true,path = "."}
sendria = {editable = true,path = "."}

[requires]
python_version = "3.7"
184 changes: 94 additions & 90 deletions Pipfile.lock

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
MailTrap
Sendria
==========

[![mailtrap version](https://img.shields.io/pypi/v/mailtrap.svg)](https://pypi.python.org/pypi/mailtrap)
[![mailtrap license](https://img.shields.io/pypi/l/mailtrap.svg)](https://pypi.python.org/pypi/mailtrap)
[![mailtrap python compatibility](https://img.shields.io/pypi/pyversions/mailtrap.svg)](https://pypi.python.org/pypi/mailtrap)
[![sendria version](https://img.shields.io/pypi/v/sendria.svg)](https://pypi.python.org/pypi/sendria)
[![sendria license](https://img.shields.io/pypi/l/sendria.svg)](https://pypi.python.org/pypi/sendria)
[![sendria python compatibility](https://img.shields.io/pypi/pyversions/sendria.svg)](https://pypi.python.org/pypi/sendria)
[![say thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/marcin%40urzenia.net)

MailTrap is a SMTP server designed to run in your dev/test environment, that is designed to catch any email you
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.
It help you prevents 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`.

MailTrap is built on shoulders of:
Sendria is built on shoulders of:
* [MailCatcher](https://mailcatcher.me/) - original idea comes of this tool by Samuel Cochran.
* [MailDump](https://github.com/ThiefMaster/maildump) - base source code of `MailTrap` (version pre 1.0.0), by Adrian Mönnich.
* [MailDump](https://github.com/ThiefMaster/maildump) - base source code of `Sendria` (version pre 1.0.0), by Adrian Mönnich.

If you like this tool, just [say thanks](https://saythanks.io/to/marcin%40urzenia.net).

Expand Down Expand Up @@ -42,58 +42,58 @@ Features
Installation
------------

`MailTrap` should work on any POSIX platform where [Python](http://python.org)
`Sendria` should work on any POSIX platform where [Python](http://python.org)
is available, it means Linux, MacOS/OSX etc.

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

python3 -m pip install mailtrap
python3 -m pip install sendria

You can also use [pipx](https://pipxproject.github.io/pipx/) if you don't want to
mess with system packages and install `MailTrap` in virtual environment:
mess with system packages and install `Sendria` in virtual environment:

pipx install mailtrap
pipx install sendria

Voila!

Python version
--------------

`MailTrap` is tested against Python 3.7+. Older Python versions may work, or may not.
`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](https://github.com/ThiefMaster/maildump).

How to use
----------

[After installing](#installation) `MailTrap`, just run command:
[After installing](#installation) `Sendria`, just run command:

mailtrap --db mails.sqlite
sendria --db mails.sqlite

Now send emails through `smtp://127.0.0.1:1025`, ie.:

```shell
echo 'From: MailTrap <mailtrap@example.com>\n'\
echo 'From: Sendria <sendria@example.com>\n'\
'To: You <[email protected]>\n'\
'Subject: Welcome!\n\n'\
'Welcome to MailTrap!' | \
curl smtp://localhost:1025 --mail-from mailtrap@example.com \
'Welcome to Sendria!' | \
curl smtp://localhost:1025 --mail-from sendria@example.com \
--mail-rcpt [email protected] --upload-file -
```

And finally look at `MailTrap` GUI on [127.0.0.1:1080](http://127.0.0.1:1080).
And finally look at `Sendria` GUI on [127.0.0.1:1080](http://127.0.0.1:1080).

If you want more details, run:

mailtrap --help
sendria --help

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


API
---

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

You can use excellent [httpie](https://httpie.org/) tool:

Expand All @@ -103,7 +103,7 @@ 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: MailTrap/1.0.0 (https://github.com/msztolcman/mailtrap)
Server: Sendria/1.0.0 (https://github.com/msztolcman/sendria)

{
"code": "OK",
Expand All @@ -120,10 +120,10 @@ Server: MailTrap/1.0.0 (https://github.com/msztolcman/mailtrap)
"recipients_message_to": [
"You <[email protected]>"
],
"sender_envelope": "mailtrap@example.com",
"sender_message": "MailTrap <mailtrap@example.com>",
"sender_envelope": "sendria@example.com",
"sender_message": "Sendria <sendria@example.com>",
"size": 191,
"source": "From: MailTrap <mailtrap@example.com>\nTo: You <[email protected]>\nSubject: Welcome!\nX-Peer: ('127.0.0.1', 59872)\nX-MailFrom: mailtrap@example.com\nX-RcptTo: [email protected]\n\nWelcome to MailTrap!\n",
"source": "From: Sendria <sendria@example.com>\nTo: You <[email protected]>\nSubject: Welcome!\nX-Peer: ('127.0.0.1', 59872)\nX-MailFrom: sendria@example.com\nX-RcptTo: [email protected]\n\nWelcome to Sendria!\n",
"subject": "Welcome!",
"type": "text/plain"
}
Expand All @@ -146,11 +146,11 @@ There are available endpoints:
Docker
------

There is also available [Docker image of MailTrap](https://hub.docker.com/layers/msztolcman/mailtrap/).
There is also available [Docker image of Sendria](https://hub.docker.com/layers/msztolcman/sendria/).
If you want to try, just run:

```shell
docker run -p 1025:1025 -p 1080:1080 msztolcman/mailtrap
docker run -p 1025:1025 -p 1080:1080 msztolcman/sendria
```

Help!
Expand All @@ -172,7 +172,7 @@ For your rails application just set in your `environments/development.rb`:
Configure Django
----------------

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

if DEBUG:
EMAIL_HOST = '127.0.0.1'
Expand All @@ -184,20 +184,20 @@ To configure Django to work with `MailTrap`, add the following to your projects'
Behind nginx
------------

If you want to hide `MailTrap` behind nginx (ie. to terminate ssl) then you can [use example
config (see in addons)](https://github.com/msztolcman/mailtrap/tree/master/addons/nginx.conf).
If you want to hide `Sendria` behind nginx (ie. to terminate ssl) then you can [use example
config (see in addons)](https://github.com/msztolcman/sendria/tree/master/addons/nginx.conf).

Supervisord
-----------

To start `Mailtrap` automatically with [Supervisor](https://supervisord.org/) there is in
[addons example config file for this purpose](https://github.com/msztolcman/mailtrap/tree/master/addons/supervisor.conf).
To start `Sendria` automatically with [Supervisor](https://supervisord.org/) there is in
[addons example config file for this purpose](https://github.com/msztolcman/sendria/tree/master/addons/supervisor.conf).

Authors
-------

* Marcin Sztolcman ([[email protected]](mailto:[email protected]))
* Adrian Mönnich (author of [MailDump](https://github.com/ThiefMaster/maildump), base of `MailTrap`)
* Adrian Mönnich (author of [MailDump](https://github.com/ThiefMaster/maildump), base of `Sendria`)

Contact
-------
Expand All @@ -206,30 +206,30 @@ If you like or dislike this software, please do not hesitate to tell me about
this me via email ([[email protected]](mailto:[email protected])).

If you find bug or have an idea to enhance this tool, please use GitHub's
[issues](https://github.com/msztolcman/mailtrap/issues).
[issues](https://github.com/msztolcman/sendria/issues).

ChangeLog
---------

### v1.0.0

* complete rewrite of backend part. MailTrap is using [asyncio](https://docs.python.org/3/library/asyncio.html) and
* complete rewrite of backend part. Sendria is using [asyncio](https://docs.python.org/3/library/asyncio.html) and
[aio-libs](https://github.com/aio-libs/) now:
* switch to [aiohttp](https://docs.aiohttp.org/) from Flask
* switch to [aiosmtpd](https://aiosmtpd.readthedocs.io) from [smtpd](https://docs.python.org/3/library/smtpd.html)
* switch to [aiosqlite](https://github.com/omnilib/aiosqlite) from [sqlite3](https://docs.python.org/3/library/sqlite3.html)
* changed logger to [structlog](https://www.structlog.org/)
* using asynchronous version of libraries drastically improved performance
* `MailTrap` now can send a webhook about every received message
* `Sendria` now can send a webhook about every received message
* show in GUI information about envelope sender and recipients
* all API requests has their own namespace now: `/api`
* allow to replace name of application or url in template
* block truncating all messages from GUI (on demand)
* fixed issues with `WebSockets`, should refresh mails list and reconnect if disconnected
* fixed issues with autobuilding assets
* many cleanups and reformatting code
* addons for [nginx](https://github.com/msztolcman/mailtrap/tree/master/addons/nginx.conf)
and [supervisor](https://github.com/msztolcman/mailtrap/tree/master/addons/supervisor.conf)
* addons for [nginx](https://github.com/msztolcman/sendria/tree/master/addons/nginx.conf)
and [supervisor](https://github.com/msztolcman/sendria/tree/master/addons/supervisor.conf)

#### Backward incompatible changes:

Expand Down
8 changes: 4 additions & 4 deletions addons/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
server {
listen ipv.4ad.dre.ss:80;
server_name mailtrap.example.com;
server_name sendria.example.com;
return 301 https://$host$request_uri;
}

server {
listen ipv.4ad.dre.ss:443 ssl http2;
server_name mailtrap.example.com;
server_name sendria.example.com;

ssl on;
ssl_certificate /path/to/mailtrap.example.com.crt;
ssl_certificate_key /path/to/mailtrap.example.com.key;
ssl_certificate /path/to/sendria.example.com.crt;
ssl_certificate_key /path/to/sendria.example.com.key;

include /etc/nginx/ssl.conf;

Expand Down
6 changes: 3 additions & 3 deletions addons/supervisor.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[program:mailtrap]
command=/usr/local/bin/mailtrap -f --db /tmp/mailtrap.sqlite
[program:sendria]
command=/usr/local/bin/sendria -f --db /tmp/sendria.sqlite
process_name=%(program_name)s
directory=/var/lib/empty
numprocs=1
Expand All @@ -12,7 +12,7 @@ startretries=1000000
exitcodes=0,2
stopsignal=TERM
stopwaitsecs=10
user=mailtrap
user=sendria
redirect_stderr=false
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stdout_logfile_maxbytes=10MB
Expand Down
3 changes: 0 additions & 3 deletions mailtrap/__main__.py

This file was deleted.

8 changes: 4 additions & 4 deletions run.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env python3
# This is a small utility to run mailtrap during development without installing it first.
# This is a small utility to run sendria during development without installing it first.

import asyncio


if __name__ == '__main__':
import mailtrap.cli
# asyncio.run(mailtrap.cli.main())
mailtrap.cli.main()
import sendria.cli
# asyncio.run(sendria.cli.main())
sendria.cli.main()
2 changes: 1 addition & 1 deletion mailtrap/__init__.py → sendria/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pkgutil

__version__ = '1.0.0'
ROOT_DIR = pathlib.Path(pkgutil.get_loader('mailtrap').get_filename()).parent
ROOT_DIR = pathlib.Path(pkgutil.get_loader('sendria').get_filename()).parent
STATIC_DIR = ROOT_DIR / 'static'
TEMPLATES_DIR = ROOT_DIR / 'templates'
ASSETS_DIR = STATIC_DIR / 'assets'
Expand Down
3 changes: 3 additions & 0 deletions sendria/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from sendria.cli import main

main()
File renamed without changes.
2 changes: 1 addition & 1 deletion mailtrap/callback.py → sendria/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async def get_session() -> aiohttp.ClientSession:
auth = aiohttp.BasicAuth(*WEBHOOK_AUTH)

headers = {
'User-agent': f'MailTrap/{__version__} (https://github.com/msztolcman/mailtrap)',
'User-agent': f'Sendria/{__version__} (https://github.com/msztolcman/sendria)',
'Content-type': 'application/javascript',
}

Expand Down
Loading

0 comments on commit c9ac80e

Please sign in to comment.