Anpassungen Anwendungspasswort web.de

This commit is contained in:
hubobel 2025-07-26 15:28:35 +02:00
parent ad82226d8d
commit 49cd480692

View file

@ -2,6 +2,7 @@ from imap_tools import MailBox
import os
import sys
import json
import telebot
def conf():
appname = os.path.basename(sys.argv[0])
@ -38,4 +39,24 @@ def conf():
passw = conf()
telegram_chat_id = passw['Telegram']['Chat_ID']
telegram_token = passw['Telegram']['TOKEN']
tb = telebot.TeleBot(telegram_token)
host = passw['mail']['mail_host']
username = passw['mail']['mail_user']
password = passw['mail']['mail_pass']
folder = passw['mail']['mail_folder']
with MailBox(host).login(username, password, folder) as mailbox:
anzahl = len(mailbox.numbers(criteria='UNSEEN'))
ankuendigung = 'Heute befinden sich ' + str(anzahl) + ' Sendungen auf dem Weg in die Hintergasse.'
tb.send_message(telegram_chat_id, ankuendigung)
for msg in mailbox.fetch(mark_seen=True,criteria='UNSEEN' ): #criteria='UNSEEN'
for att in msg.attachments:
fn = att.filename
ext = (att.content_type[-3:])
fn = str(msg.uid) + fn +'.'+ ext
with open(fn, 'wb') as f:
f.write(att.payload)
document = open(fn, 'rb')
tb.send_document(telegram_chat_id, document, caption=msg.date)
os.remove(fn)