# Path: photobooth/worker/WorkerTask.py
# class WorkerTask:
# 
#     def __init__(self, **kwargs):
# 
#         assert not kwargs
# 
#     def do(self, picture):
# 
#         raise NotImplementedError()


import logging
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
from email.utils import formatdate
from email import encoders
from pathlib import Path
from .WorkerTask import WorkerTask
        port (int): port number
        is_auth (bool): server requires authentication
        username (str): server auth username
        password (str): server auth password
        is_tls (bool): use TLS mode
    """
    msg = MIMEMultipart()
    msg['From'] = send_from
    msg['To'] = send_to
    msg['Date'] = formatdate(localtime=True)
    msg['Subject'] = subject

    msg.attach(MIMEText(message))

    part = MIMEBase('application', "octet-stream")
    part.set_payload(picture.getbuffer())
    encoders.encode_base64(part)
    part.add_header('Content-Disposition',
                    'attachment; filename="{}"'.format(filename))
    msg.attach(part)

    smtp = smtplib.SMTP(server, port)
    if is_tls:
        smtp.starttls()
    if is_auth:
        smtp.login(username, password)
    smtp.sendmail(send_from, send_to, msg.as_string())
    smtp.quit()



# Path: photobooth/worker/WorkerTask.py
# class WorkerTask:
# 
#     def __init__(self, **kwargs):
# 
#         assert not kwargs
# 
#     def do(self, picture):
# 
#         raise NotImplementedError()


# Path: photobooth/worker/PictureMailer.py
import logging
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
from email.utils import formatdate
from email import encoders
from pathlib import Path
from .WorkerTask import WorkerTask

        port (int): port number
        is_auth (bool): server requires authentication
        username (str): server auth username
        password (str): server auth password
        is_tls (bool): use TLS mode
    """
    msg = MIMEMultipart()
    msg['From'] = send_from
    msg['To'] = send_to
    msg['Date'] = formatdate(localtime=True)
    msg['Subject'] = subject

    msg.attach(MIMEText(message))

    part = MIMEBase('application', "octet-stream")
    part.set_payload(picture.getbuffer())
    encoders.encode_base64(part)
    part.add_header('Content-Disposition',
                    'attachment; filename="{}"'.format(filename))
    msg.attach(part)

    smtp = smtplib.SMTP(server, port)
    if is_tls:
        smtp.starttls()
    if is_auth:
        smtp.login(username, password)
    smtp.sendmail(send_from, send_to, msg.as_string())
    smtp.quit()



class PictureMailer(WorkerTask):