added email routing with exim4 via /etc/aliases

This commit is contained in:
b3yond 2018-09-23 18:53:46 +02:00
parent 36c21dbfbb
commit 244bde51b6
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: To Do:
```shell ```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 cd /srv
sudo git clone https://github.com/b3yond/ticketfrei sudo git clone https://github.com/b3yond/ticketfrei
cd 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 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: Deploy ticketfrei with uwsgi:
```shell ```shell

View file

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

View file

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

4
db.py
View file

@ -1,7 +1,7 @@
from config import config from config import config
import jwt import jwt
import logging import logging
from os import urandom from os import urandom, system
from pylibscrypt import scrypt_mcf from pylibscrypt import scrypt_mcf
import sqlite3 import sqlite3
@ -257,6 +257,8 @@ u\d\d?"""
(uid, "bastard")) (uid, "bastard"))
else: else:
uid = json['uid'] 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(?, ?);", self.execute("INSERT INTO email (user_id, email) VALUES(?, ?);",
(uid, json['email'])) (uid, json['email']))
self.execute("""INSERT INTO telegram_accounts (user_id, apikey, self.execute("""INSERT INTO telegram_accounts (user_id, apikey,