Sends the message. Args: message (str): The message to send. Returns: dict: A dictionary containing the result of the attempt to send the email.
(self, message)
| 30 | |
| 31 | @retry(stop=stop_after_attempt(3)) |
| 32 | def notify(self, message): |
| 33 | """Sends the message. |
| 34 | |
| 35 | Args: |
| 36 | message (str): The message to send. |
| 37 | |
| 38 | Returns: |
| 39 | dict: A dictionary containing the result of the attempt to send the email. |
| 40 | """ |
| 41 | |
| 42 | header = 'From: %s\n' % self.username |
| 43 | header += 'To: %s\n' % self.destination_addresses |
| 44 | header += 'Content-Type: text/plain\n' |
| 45 | header += 'Subject: Crypto-signal alert!\n\n' |
| 46 | message = header + message |
| 47 | |
| 48 | smtp_handler = smtplib.SMTP(self.smtp_server) |
| 49 | smtp_handler.starttls() |
| 50 | smtp_handler.login(self.username, self.password) |
| 51 | result = smtp_handler.sendmail(self.username, self.destination_addresses, message) |
| 52 | smtp_handler.quit() |
| 53 | return result |
no outgoing calls
no test coverage detected