def _send_email(self, check):
        check_name = check['check']
        hostname = check['hostname']
        if check['status'] is True:
            status = 'UP'
        else:
            status = 'DOWN'
        subject = "[stalker] %s on %s is %s" % (check_name, hostname, status)
        message = """From: %s
        To: %s
        Subject: %s

        %s
        """ % (self.from_addr, self.recipients, subject, check)
        try:
            conn = smtplib.SMTP(self.smtp_host, self.smtp_port)
            conn.ehlo()
            conn.sendmail(self.from_addr, self.recipients, message)
            conn.close()
            self.logger.info('Email sent for: %s' % check)
            return True
        except Exception:
            self.logger.exception('Email notification error.')
            return False
dataset/ETHPy150Open pandemicsyn/stalker/stalkeragent/stalkeragent/stalker_notifications.py/EmailNotify._send_email/original