added email routing with exim4 via /etc/aliases

master
b3yond 2018-09-23 18:53:46 +02:00
parent dbcd2cd6ee
commit 531c027f04
4 changed files with 24 additions and 4 deletions

View File

@ -75,7 +75,7 @@ We wrote these installation notes, so you can set up the website easily:
To Do:
```shell
sudo apt install python3 virtualenv uwsgi uwsgi-plugin-python3 nginx git
sudo apt install python3 virtualenv uwsgi uwsgi-plugin-python3 nginx git exim4
cd /srv
sudo git clone https://github.com/b3yond/ticketfrei
cd ticketfrei
@ -110,6 +110,22 @@ sudo apt-get install python-certbot-nginx -t stretch-backports
sudo certbot --authenticator webroot --installer nginx --agree-tos --redirect --hsts
```
Configure exim4 for using mbox files.
```
sudo dpkg-reconfigure exim4-config
# Choose the following values:
# internet site; mail is sent and received directly using SMTP
# your domain name
#
# your domain name
#
#
# No
# mbox format in /var/mail/
# No
```
Deploy ticketfrei with uwsgi:
```shell

View File

@ -19,10 +19,11 @@ class Mailbot(Bot):
def crawl(self, user):
reports = []
# todo: adjust to actual mailbox
mails = mailbox.mbox('/var/mail/test')
mails = mailbox.mbox("/var/mail/" + config['mail']['mbox_user'])
for msg in mails:
if get_date_from_header(msg['Date']) > user.get_seen_mail():
reports.append(make_report(msg, user))
if user.get_city() in msg['To']:
reports.append(make_report(msg, user))
return reports
# post/boost Report object

View File

@ -13,6 +13,7 @@ contact = "b3yond@riseup.net"
mailserver = "smtp.riseup.net"
user = "user"
passphrase = "sup3rs3cur3"
mbox = "root"
[database]
db_path = "/var/ticketfrei/db.sqlite"

4
db.py
View File

@ -1,7 +1,7 @@
from config import config
import jwt
import logging
from os import urandom
from os import urandom, system
from pylibscrypt import scrypt_mcf
import sqlite3
@ -257,6 +257,8 @@ u\d\d?"""
(uid, "bastard"))
else:
uid = json['uid']
with open("/etc/aliases", "a+") as f:
f.write(city + ": " + config["mail"]["mbox_user"])
self.execute("INSERT INTO email (user_id, email) VALUES(?, ?);",
(uid, json['email']))
self.execute("""INSERT INTO telegram_accounts (user_id, apikey,