def __send_email(self, to=None, BCC=None, html_body=None, title=None): message = Message(From=self.mailer_config['from'],To=to, BCC=BCC ) message.Subject = title if title is not None else 'EC2 Instance Alert' message.Html = html_body mailer_url_data = self.mailer_config['mailserver'].split(':') sender = Mailer(host=mailer_url_data[0], port=mailer_url_data[1], use_tls=True if self.mailer_config['use_tls'] == '1' else False, usr=self.mailer_config['auth_username'], pwd=self.mailer_config['auth_password']) sender.send(message)
def send_email(self, to=None, BCC=None, html_body=None, title=None): # message = Message(From=self.mailer_config['from'],To=to, BCC=BCC, charset='utf-8' ) message = Message(From=self.mailer_config['from'],To=to, BCC=BCC ) message.Subject = title if title is not None else 'A Daily Report' message.Html = html_body mailer_url_data = self.mailer_config['mailserver'].split(':') sender = Mailer(host=mailer_url_data[0], port=mailer_url_data[1], use_tls=True if self.mailer_config['use_tls'] == '1' else False, usr=self.mailer_config['auth_username'], pwd=self.mailer_config['auth_password']) try: sender.send(message) except SMTPDataError as e: print "%s - %s" % (to, e)