2022-02-07 13:54:57 +00:00
|
|
|
#!/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())
|
2022-02-07 13:57:00 +00:00
|
|
|
f.unlink()
|
2022-02-07 13:54:57 +00:00
|
|
|
|
|
|
|
smtp = SMTP.fromConfig(config)
|
|
|
|
|
|
|
|
for message in messages:
|
|
|
|
smtp.send_message(message)
|