# Path: robograph/datamodel/base/node.py
# class Node:
#     def __init__(self, **args):
#     def name(self):
#     def requirements(self):
#     def parameters(self):
#     def output_label(self):
#     def input(self, context):
#     def set_output_label(self, output_label):
#     def output(self):
#     def execute(self):
#     def reset(self):
#     def __repr__(self):


from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from smtplib import SMTP
from robograph.datamodel.base import node

class SmtpClient:
    """
    Utility class representing an SMTP client
    """
    def __init__(self, server_hostname, server_port, username, password,
                 use_tls=True):
        self._server_hostname = server_hostname
        self._server_port = server_port
        self._username = username
        self._password = password
        self._use_tls = use_tls

    def send(self, subject, body, recipients_list, sender, mime='html'):
        if mime == 'text':
            msg = MIMEText(body)
        else:
            msg = MIMEMultipart('alternative')
            msg.attach(MIMEText(body, 'html'))
        msg['Subject'] = subject

        # Send
        server = SMTP(self._server_hostname + ':' + str(self._server_port))
        if self._use_tls:
            server.starttls()
        server.login(self._username, self._password)
        server.sendmail(sender, recipients_list, msg.as_string())
        server.quit()



# Path: robograph/datamodel/base/node.py
# class Node:
#     def __init__(self, **args):
#     def name(self):
#     def requirements(self):
#     def parameters(self):
#     def output_label(self):
#     def input(self, context):
#     def set_output_label(self, output_label):
#     def output(self):
#     def execute(self):
#     def reset(self):
#     def __repr__(self):


# Path: robograph/datamodel/nodes/lib/email.py
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from smtplib import SMTP
from robograph.datamodel.base import node


class SmtpClient:
    """
    Utility class representing an SMTP client
    """
    def __init__(self, server_hostname, server_port, username, password,
                 use_tls=True):
        self._server_hostname = server_hostname
        self._server_port = server_port
        self._username = username
        self._password = password
        self._use_tls = use_tls

    def send(self, subject, body, recipients_list, sender, mime='html'):
        if mime == 'text':
            msg = MIMEText(body)
        else:
            msg = MIMEMultipart('alternative')
            msg.attach(MIMEText(body, 'html'))
        msg['Subject'] = subject

        # Send
        server = SMTP(self._server_hostname + ':' + str(self._server_port))
        if self._use_tls:
            server.starttls()
        server.login(self._username, self._password)
        server.sendmail(sender, recipients_list, msg.as_string())
        server.quit()



class SmtpEmail(node.Node):