add -*- coding: utf-8 -*-
parent
c87e01acff
commit
0f179e4364
|
|
@ -3,6 +3,7 @@
|
||||||
import mysql.connector
|
import mysql.connector
|
||||||
import datetime
|
import datetime
|
||||||
import smtplib
|
import smtplib
|
||||||
|
import ssl
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
import argparse
|
import argparse
|
||||||
|
|
@ -12,9 +13,16 @@ from dotenv import load_dotenv
|
||||||
|
|
||||||
|
|
||||||
def get_tables_from_db(connection):
|
def get_tables_from_db(connection):
|
||||||
|
"""
|
||||||
|
Holt die Liste der zu überprüfenden Tabellen, die 'RAW.' im Namen enthalten
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list: Liste der Tabellennamen
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
|
# Holen aller Tabellen in der Kunden-Datenbank
|
||||||
cursor.execute("SHOW TABLES FROM Kunden")
|
cursor.execute("SHOW TABLES FROM Kunden")
|
||||||
tables = []
|
tables = []
|
||||||
|
|
||||||
|
|
@ -135,9 +143,12 @@ def send_email(outdated_tables, database, email_config):
|
||||||
message.attach(MIMEText(body, "plain"))
|
message.attach(MIMEText(body, "plain"))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Verbindung zum SMTP-Server herstellen
|
# Verbindung zum SMTP-Server herstellen mit TLS
|
||||||
|
context = ssl.create_default_context()
|
||||||
server = smtplib.SMTP(smtp_server, smtp_port)
|
server = smtplib.SMTP(smtp_server, smtp_port)
|
||||||
server.starttls() # TLS-Verschlüsselung aktivieren
|
server.ehlo() # Kann bei manchen Servern erforderlich sein
|
||||||
|
server.starttls(context=context) # TLS-Verschlüsselung aktivieren mit sicherem Kontext
|
||||||
|
server.ehlo() # Nach TLS erneut ehlo senden
|
||||||
|
|
||||||
# Anmelden (falls erforderlich)
|
# Anmelden (falls erforderlich)
|
||||||
if smtp_password:
|
if smtp_password:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue