Skip to content

Commit

Permalink
cleanup and enhanced logs
Browse files Browse the repository at this point in the history
  • Loading branch information
geek-at committed Nov 18, 2023
1 parent 820f75e commit 90f7bcb
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 22 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ data/*
.git
.github
docs
logs/*
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ Just edit the `config.ini` You can use the following settings
- `ADMIN` -> An email address (doesn't have to exist, just has to be valid) that will list all emails of all addresses the server has received. Kind of a catch-all
- `DATEFORMAT` -> How should timestamps be shown on the web interface ([moment.js syntax](https://momentjs.com/docs/#/displaying/))

## Docker env vars
In Docker you can use the following environment variables:

| ENV var | What it does | Example values |
| --------|--------------|----------|
| URL | The URL of the web interface. Used by the API and RSS feed | http://localhost:8080 |
| DISCARD_UNKNOWN | Tells the Mailserver to wether or not delete emails that are addressed to domains that are not configured | true, false |
| DOMAINS | The whitelisted Domains the server will listen for. If DISCARD_UNKNOWN is set to false, this will only be used to generate random emails in the webinterface |
| SHOW_ACCOUNT_LIST | If set to `true`, all accounts that have previously received emails can be listed via API or webinterface | true,false |
| ADMIN | If set to a valid email address and this address is entered in the API or webinterface, will show all emails of all accounts. Kind-of catch-all | test@test.com
| DATEFORMAT | Will format the received date in the web interface based on [moment.js](https://momentjs.com/) syntax | "MMMM Do YYYY, h:mm:ss a" |


# Roadmap
- [x] Mail server
- [x] Storing received mails in JSON
Expand Down Expand Up @@ -135,17 +148,4 @@ docker run -d --restart=unless-stopped --name opentrashmail -e "DOMAINS=mydomain

# How it works

The heart of Open Trashmail is a **Python-powered SMTP server** that listens on incoming emails and stores them as JSON files. The server doesn't have to know the right email domain, it will just **catch everything** it receives. You only have to **expose port 25 to the web** and set an **MX record** of your domain pointing to the IP address of your machine.

# Configuration

In Docker you can use the following environment variables:

| ENV var | What it does | Example values |
| --------|--------------|----------|
| DISCARD_UNKNOWN | Tells the Mailserver to wether or not delete emails that are addressed to domains that are not configured | true, false |
| DOMAINS | The whitelisted Domains the server will listen for. If DISCARD_UNKNOWN is set to false, this will only be used to generate random emails in the webinterface |
| URL | The URL of the web interface. Used by the API and RSS feed | http://localhost:8080 |
| SHOW_ACCOUNT_LIST | If set to `true`, all accounts that have previously received emails can be listed via API or webinterface | true,false |
| ADMIN | If set to a valid email address and this address is entered in the API or webinterface, will show all emails of all accounts. Kind-of catch-all | test@test.com
| DATEFORMAT | Will format the received date in the web interface based on [moment.js](https://momentjs.com/) syntax | "MMMM Do YYYY, h:mm:ss a" |
The heart of Open Trashmail is a **Python-powered SMTP server** that listens on incoming emails and stores them as JSON files. The server doesn't have to know the right email domain, it will just **catch everything** it receives. You only have to **expose port 25 to the web** and set an **MX record** of your domain pointing to the IP address of your machine.
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ RUN sed -i 's/nobody/nginx/g' /etc/php7/php-fpm.d/www.conf
WORKDIR /var/www/opentrashmail

# Volumes to mount
#VOLUME /var/lib/influxdb
VOLUME /var/www/opentrashmail/data
VOLUME /var/www/opentrashmail/logs

EXPOSE 80 25

Expand Down
4 changes: 2 additions & 2 deletions docker/rootfs/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ server {


# logging
access_log /var/log/nginx/opentrashmail/web.access.log;
error_log /var/log/nginx/opentrashmail/web.error.log warn;
access_log /var/www/opentrashmail/logs/web.access.log;
error_log /var/www/opentrashmail/logs/web.error.log warn;

location ~ \.php$ {
# 404
Expand Down
2 changes: 1 addition & 1 deletion docker/rootfs/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ fi
chown -R nginx:nginx /var/www/opentrashmail/data

echo ' [+] Starting Mailserver'
su - nginx -s /bin/ash -c 'cd /var/www/opentrashmail/python;python mailserver.py'
su - nginx -s /bin/ash -c 'cd /var/www/opentrashmail/python;python mailserver.py > /var/www/opentrashmail/logs/mailserver.log 2>&1 '
2 changes: 2 additions & 0 deletions logs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
1 change: 0 additions & 1 deletion python/mailserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def process_message(self, peer, mailfrom, rcpttos, data):
except:
logger.exception('Error reading incoming email')
else:
# this data will be sent as POST data
edata = {
'subject': subject,
'body': body,
Expand Down
File renamed without changes.
3 changes: 0 additions & 3 deletions web/css/default.min.css:Zone.Identifier

This file was deleted.

0 comments on commit 90f7bcb

Please sign in to comment.