fix email test sending
@@ -153,9 +153,9 @@ class CoreSettings(BaseAuditModel):
def send_mail(self, subject, body, alert_template=None, test=False):
- if not alert_template or not self.email_is_configured:
+ if not alert_template and not self.email_is_configured:
if test:
- return "Missing required fields (need at least 1 recipient)"
+ return "Email server settings are not configured correctly"
return False
# override email from if alert_template is passed and is set
@@ -170,6 +170,9 @@ class CoreSettings(BaseAuditModel):
else:
email_recipients = ", ".join(self.email_alert_recipients)
+ if not email_recipients:
+ return "There needs to be at least one email recipient configured"
+
try:
msg = EmailMessage()
msg["Subject"] = subject
@@ -197,7 +200,7 @@ class CoreSettings(BaseAuditModel):
return True
def send_sms(self, body, alert_template=None, test=False):
- if not alert_template or not self.sms_is_configured:
+ if not alert_template and not self.sms_is_configured:
return "Sms alerting is not setup correctly."
# override email recipients if alert_template is passed and is set
