def send(self, reply_to=None, recipients=["*****@*****.**"], html_msg='This is a <b>test</b> message!', subject="KDM-Manager!"): """ Generic Emailer. Accepts a list of 'recipients', a 'msg' string and a sender name (leave undefinied to use [email protected]). """ author = email.utils.formataddr( (str(email_Header(self.sender_name, 'utf-8')), self.no_reply)) msg = MIMEMultipart('alternative') msg['From'] = author msg['Subject'] = subject msg['To'] = recipients[0] if reply_to is not None: msg.add_header('reply-to', reply_to) msg.attach(MIMEText(html_msg.encode("utf-8"), 'html')) self.server.sendmail(self.no_reply, recipients, msg.as_string()) self.server.quit() self.logger.debug("Email sent successfully!")
def send(self, reply_to=None, subject="KD:M API", recipients=API.config['ADMIN_EMAIL_ADDRESSES'], html_msg='This is a <b>test</b> message!'): """ Generic Emailer. Accepts a list of 'recipients', a 'msg' string and a sender name (leave undefinied to use [email protected]). """ author = email.utils.formataddr( (str(email_Header(self.sender_name, 'utf-8')), self.no_reply)) msg = MIMEMultipart('alternative') msg['From'] = author msg['Subject'] = subject msg['To'] = recipients[0] if reply_to is not None: msg.add_header('reply-to', reply_to) # msg.attach(MIMEText(html_msg.encode('ascii','ignore'),'html')) msg.attach(MIMEText(html_msg, 'html')) self.server.sendmail(self.no_reply, recipients, msg.as_string()) self.server.quit() self.logger.debug("Email sent successfully!")