29 lines
618 B
Python
29 lines
618 B
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
import pathlib
|
||
|
|
||
|
from classes.config import Config
|
||
|
from classes.mission import Mission
|
||
|
from classes.smtp import SMTP
|
||
|
|
||
|
|
||
|
config = Config("settings.ini")
|
||
|
|
||
|
tempdir = pathlib.Path(config["MONSTER"].get("TempDir", "/tmp/MailMonster/"))
|
||
|
|
||
|
if not tempdir.exists():
|
||
|
tempdir.mkdir()
|
||
|
|
||
|
elif not tempdir.isdir():
|
||
|
raise ValueError(f"Temp Dir {str(tempdir)} exists and is not a directory.")
|
||
|
|
||
|
messages = []
|
||
|
|
||
|
for f in tempdir.glob("*.mmm"):
|
||
|
mission = Mission.fromFile(f)
|
||
|
messages.append(mission.to_message())
|
||
|
|
||
|
smtp = SMTP.fromConfig(config)
|
||
|
|
||
|
for message in messages:
|
||
|
smtp.send_message(message)
|