diff --git a/src/modules/DashboardConfig.py b/src/modules/DashboardConfig.py index a50e8c53..8ca8fd8f 100644 --- a/src/modules/DashboardConfig.py +++ b/src/modules/DashboardConfig.py @@ -73,6 +73,7 @@ class DashboardConfig: "encryption": "", "username": "", "email_password": "", + "authentication_required": "true", "send_from": "", "email_template": "" }, diff --git a/src/modules/Email.py b/src/modules/Email.py index 61c2b8c4..3bfc595d 100644 --- a/src/modules/Email.py +++ b/src/modules/Email.py @@ -31,9 +31,15 @@ class EmailSender: def SendFrom(self): return self.DashboardConfig.GetConfig("Email", "send_from")[1] + + # Thank you, @gdeeble from GitHub + def AuthenticationRequired(self): + return self.DashboardConfig.GetConfig("Email", "authentication_required")[1] def ready(self): - return all([self.Server(), self.Port(), self.Encryption(), self.Username(), self.Password(), self.SendFrom()]) + if self.AuthenticationRequired(): + return all([self.Server(), self.Port(), self.Encryption(), self.Username(), self.Password(), self.SendFrom()]) + return all([self.Server(), self.Port(), self.Encryption(), self.SendFrom()]) def send(self, receiver, subject, body, includeAttachment = False, attachmentName = "") -> tuple[bool, str] | tuple[bool, None]: if self.ready(): @@ -42,7 +48,9 @@ class EmailSender: self.smtp.ehlo() if self.Encryption() == "STARTTLS": self.smtp.starttls() - self.smtp.login(self.Username(), self.Password()) + if self.AuthenticationRequired(): + print("Login") + self.smtp.login(self.Username(), self.Password()) message = MIMEMultipart() message['Subject'] = subject message['From'] = self.SendFrom() diff --git a/src/static/app/src/components/settingsComponent/dashboardEmailSettings.vue b/src/static/app/src/components/settingsComponent/dashboardEmailSettings.vue index 3b593d0a..6b9334d0 100644 --- a/src/static/app/src/components/settingsComponent/dashboardEmailSettings.vue +++ b/src/static/app/src/components/settingsComponent/dashboardEmailSettings.vue @@ -13,7 +13,7 @@ onMounted(() => { await fetchPost("/api/updateDashboardConfigurationItem", { section: "Email", key: id, - value: x.value + value: store.Configuration.Email[id] }, (res) => { if (res.status){ x.classList.remove('is-invalid') @@ -71,6 +71,16 @@ const sendTestEmail = async () => {
+
+
+ + +
+
+ type="text" class="form-control rounded-3">
@@ -92,7 +102,7 @@ const sendTestEmail = async () => { + type="text" class="form-control rounded-3">
@@ -102,7 +112,7 @@ const sendTestEmail = async () => { -
-
+
+ type="text" class="form-control rounded-3">
-
+
+ type="password" class="form-control rounded-3">
+
+ type="text" class="form-control rounded-3">
+