mirror of
https://github.com/skoelle/icloud-contacts-sync.git
synced 2026-09-17 15:30:24 +00:00
mail only when some has birthday
This commit is contained in:
@@ -100,6 +100,8 @@ Siehe `sql/schema.sql`. Wichtigste Änderungen gegenüber v1:
|
||||
konfigurierten Stunde (Default 7 Uhr).
|
||||
- Query: alle Kontakte über alle Accounts hinweg, deren `birthday`
|
||||
(Monat/Tag) auf das heutige Datum fällt.
|
||||
- Versand nur bei existierenden Geburtstagen: Wird keine E-Mail
|
||||
versendet, wenn die Abfrage keine Treffer liefert.
|
||||
- Versand per SMTP mit STARTTLS (`smtplib`), Konfiguration über
|
||||
`SMTP_HOST`, `SMTP_PORT`, `SMTP_USER`, `SMTP_PASSWORD`, `MAIL_FROM`,
|
||||
`MAIL_TO`.
|
||||
|
||||
+5
-1
@@ -11,8 +11,8 @@ import sys
|
||||
from datetime import date
|
||||
from email.message import EmailMessage
|
||||
|
||||
from config import Config
|
||||
import db
|
||||
from config import Config
|
||||
|
||||
logging.basicConfig(level=Config.LOG_LEVEL, format="%(asctime)s [%(levelname)s] %(message)s")
|
||||
logger = logging.getLogger("mailer")
|
||||
@@ -181,6 +181,10 @@ def main() -> int:
|
||||
return 0
|
||||
|
||||
birthdays = fetch_todays_birthdays(conn)
|
||||
if not birthdays:
|
||||
logger.info("Keine Geburtstage heute, überspringe Mailversand")
|
||||
return 0
|
||||
|
||||
msg = build_message(birthdays)
|
||||
try:
|
||||
send_message(msg)
|
||||
|
||||
Reference in New Issue
Block a user