# Path: core/config.py



import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from core.config import conf_notifications, notifications



conf_mail = conf_notifications['smtp']

def _sendmail(fromaddr, toaddrs, text, html, subject):

    msg = MIMEMultipart('alternative')
    msg['Subject'] = subject
    msg['From'] = fromaddr
    msg['To'] = ', '.join(toaddrs)

    part1 = MIMEText(text, 'plain')
    part2 = MIMEText(html, 'html')
    
    msg.attach(part1)
    msg.attach(part2)

    server = smtplib.SMTP(conf_mail['host'])
    server.set_debuglevel(1)
    server.sendmail(fromaddr, toaddrs, msg.as_string())
    server.quit()

def _compose_mail(notification_data):
    text = notifications.get_template('%s.tpl' % conf_mail['template_text']).render(**notification_data)

# Path: core/config.py



# Path: core/notifications/notify_smtp.py
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from core.config import conf_notifications, notifications




conf_mail = conf_notifications['smtp']

def _sendmail(fromaddr, toaddrs, text, html, subject):

    msg = MIMEMultipart('alternative')
    msg['Subject'] = subject
    msg['From'] = fromaddr
    msg['To'] = ', '.join(toaddrs)

    part1 = MIMEText(text, 'plain')
    part2 = MIMEText(html, 'html')
    
    msg.attach(part1)
    msg.attach(part2)

    server = smtplib.SMTP(conf_mail['host'])
    server.set_debuglevel(1)
    server.sendmail(fromaddr, toaddrs, msg.as_string())
    server.quit()

def _compose_mail(notification_data):
    text = notifications.get_template('%s.tpl' % conf_mail['template_text']).render(**notification_data)

    html = notifications.get_template('%s.tpl' % conf_mail['template_html']).render(**notification_data)