diff --git a/src/components/notifications/SendGrid.vue b/src/components/notifications/SendGrid.vue
index 18118f469..01d4f453b 100644
--- a/src/components/notifications/SendGrid.vue
+++ b/src/components/notifications/SendGrid.vue
@@ -5,21 +5,65 @@
-
-
{{ $t("Separate multiple email addresses with commas") }}
+
+
{{ $t("Separate multiple email addresses with commas") }}
+
+ {{ $t("Please use format: Friendly Name or just email@domain.com for each address") }}
+
@@ -38,6 +82,46 @@ export default {
components: {
HiddenInput,
},
+
+ data() {
+ return {
+ errors: {
+ from: false,
+ to: false,
+ cc: false,
+ bcc: false
+ }
+ }
+ },
+
+ methods: {
+ isValidEmailFormat(value) {
+ const friendlyEmailRegex = /^[^<>]+ <[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}>$/;
+ const emailOnlyRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
+ return friendlyEmailRegex.test(value) || emailOnlyRegex.test(value);
+ },
+
+ validateEmail(event, field) {
+ const value = event.target.value;
+
+ if (!value) {
+ this.errors[field] = false;
+ return;
+ }
+
+ if (field === 'cc' || field === 'bcc') {
+ if (value.includes(',')) {
+ this.errors[field] = !value.split(',')
+ .map(email => email.trim())
+ .every(email => this.isValidEmailFormat(email));
+ return;
+ }
+ }
+
+ this.errors[field] = !this.isValidEmailFormat(value);
+ }
+ },
+
mounted() {
if (typeof this.$parent.notification.sendgridSubject === "undefined") {
this.$parent.notification.sendgridSubject = "Notification from Your Uptime Kuma";
@@ -45,3 +129,14 @@ export default {
},
};
+
+
\ No newline at end of file