bump files
This commit is contained in:
@@ -1,19 +1,36 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
from omegaconf import OmegaConf
|
||||
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
|
||||
from src import Icon
|
||||
from src import Icon, settings as config
|
||||
from src.logic.log import MyLogger
|
||||
|
||||
from .dialog_sources.Ui_mail_preview import Ui_eMailPreview as MailPreviewDialog
|
||||
from .mailTemplate import MailTemplateDialog
|
||||
|
||||
config = OmegaConf.load("config.yaml")
|
||||
|
||||
logger = MyLogger("Mail")
|
||||
|
||||
empty_signature = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
|
||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style
|
||||
type="text/css">
|
||||
|
||||
p, li { white-space: pre-wrap; }
|
||||
|
||||
hr { height: 1px; border-width: 0; }
|
||||
|
||||
li.unchecked::marker { content: "\2610"; }
|
||||
|
||||
li.checked::marker { content: "\2612"; }
|
||||
|
||||
</style></head><body style=" font-family:''Segoe UI''; font-size:9pt; font-weight:400;
|
||||
font-style:normal;">
|
||||
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px;
|
||||
margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>
|
||||
"""
|
||||
|
||||
class Mail_Dialog(QtWidgets.QDialog, MailPreviewDialog):
|
||||
def __init__(
|
||||
@@ -73,11 +90,11 @@ class Mail_Dialog(QtWidgets.QDialog, MailPreviewDialog):
|
||||
pass
|
||||
|
||||
def determine_signature(self):
|
||||
if config.mail.signature is None:
|
||||
if config.mail.signature is empty_signature or config.mail.signature == "":
|
||||
return """Mit freundlichen Grüßen
|
||||
Ihr Semesterapparatsteam
|
||||
Mail: semesterapparate@ph-freiburg.de
|
||||
Tel.: 0761/682-778"""
|
||||
Tel.: 0761/682-778 | 07617682-545"""
|
||||
else:
|
||||
return config.mail.signature
|
||||
|
||||
@@ -140,10 +157,10 @@ Tel.: 0761/682-778"""
|
||||
|
||||
tolist = [self.prof_mail, "semesterapparate@ph-freiburg.de"]
|
||||
self.btn_okay.setText("Mail wird gesendet")
|
||||
smtp_server = config["mail"]["smtp_server"]
|
||||
port: int = config["mail"]["port"]
|
||||
sender_email = config["mail"]["sender"]
|
||||
password = config["mail"]["password"]
|
||||
smtp_server = config.mail.smtp_server
|
||||
port: int = config.mail.port
|
||||
sender_email = config.mail.sender
|
||||
password = config.mail.password
|
||||
message = MIMEMultipart()
|
||||
message["From"] = sender_email
|
||||
message["To"] = self.prof_mail
|
||||
@@ -155,18 +172,21 @@ Tel.: 0761/682-778"""
|
||||
message.attach(MIMEText(mail_body, "html"))
|
||||
mail = message.as_string()
|
||||
|
||||
server = smtplib.SMTP_SSL(smtp_server, port)
|
||||
# server.starttls()
|
||||
with smtplib.SMTP_SSL(smtp_server, port) as server:
|
||||
server.connect(smtp_server, port)
|
||||
# server.connect(smtp_server, port)
|
||||
# server.auth(mechanism="PLAIN")
|
||||
if config["mail"]["use_user_name"] is True:
|
||||
# print(config["mail"]["user_name"])
|
||||
server.login(config["mail"]["user_name"], password)
|
||||
else:
|
||||
server.login(sender_email, password)
|
||||
server.sendmail(sender_email, tolist, mail)
|
||||
if config.mail.use_user_name is True:
|
||||
# print(config["mail"]["user_name"])
|
||||
|
||||
server.login(config.mail.user_name, password)
|
||||
else:
|
||||
server.login(sender_email, password)
|
||||
server.sendmail(sender_email, tolist, mail)
|
||||
|
||||
# print("Mail sent")
|
||||
# end active process
|
||||
server.quit()
|
||||
server.quit()
|
||||
logger.log_info("Mail sent, closing connection to server and dialog")
|
||||
# close the dialog
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ Content-Transfer-Encoding: 8bit
|
||||
# warning dialog
|
||||
Icon("template_fail", self.testTemplate)
|
||||
dialog = QtWidgets.QMessageBox()
|
||||
dialog.setIcon(Icon("warning").icon)
|
||||
Icon("warning", dialog)
|
||||
|
||||
dialog.setText("Folgende Platzhalter fehlen im Template:")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user