Conditions | 3 |
Total Lines | 15 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 1 |
CRAP Score | 9.762 |
Changes | 0 |
1 | #!/usr/bin/python |
||
21 | 1 | def __init__(self) -> None: |
|
22 | """Initializing action. Validate SMTP connection and user settings""" |
||
23 | self._smtp = SMTP(host=Settings.Notification.Mail.smtp_server, port=Settings.Notification.Mail.smtp_port) |
||
24 | self._smtp.ehlo() |
||
25 | self._smtp.starttls() |
||
26 | |||
27 | # status code 250 is OK |
||
28 | response = self._smtp.noop() |
||
29 | if not response[0] == 250: |
||
30 | raise InvalidSMTPSettingsException('Invalid SMTP Server settings') |
||
31 | |||
32 | try: |
||
33 | self._smtp.login(Settings.Notification.Mail.sender_mail, Settings.Notification.Mail.sender_pass) |
||
34 | except SMTPAuthenticationError: |
||
35 | raise InvalidMailSettingsException('Invalid user credentials for the SMTP server') |
||
36 | |||
54 |