# Path: nflpool/email/template_parser.py
# class EmailTemplateParser:
#     welcome = None
#     reset_password = None
# 
#     @staticmethod
#     def global_init():
#         templates = os.path.join(os.path.dirname(__file__), "templates")
#         welcome_file = os.path.join(templates, "welcome.html")
#         with open(welcome_file) as fin:
#             EmailTemplateParser.welcome = fin.read()
# 
#         welcome_file = os.path.join(templates, "password_reset.html")
#         with open(welcome_file) as fin:
#             EmailTemplateParser.reset_password = fin.read()
# 
#     @staticmethod
#     def expand(template, data):
# 
#         final_text = template
#         for k in data:
#             key = "{" + k + "}"
#             final_text = final_text.replace(key, data[k])
# 
#         return final_text


import mailer
import html2text
from nflpool.email.template_parser import EmailTemplateParser
                From=EmailService.__from_address, To=to_address, charset="utf-8"
            )
            message.Subject = subject
            message.Html = html_body
            message.Body = html2text.html2text(html_body)

            if not EmailService.__is_debug_mode:
                print("Sending message (live!)")
                smtp.send(message)
            else:
                print("Skipping send, email is in dev mode.")
        except Exception as x:
            print("Error sending mail: {}".format(x))

    @staticmethod
    def create_smtp_server():
        smtp = mailer.Mailer(
            host=EmailService.__smtp_server,
            port=EmailService.__smtp_port,
            usr=EmailService.__smtp_username,
            pwd=EmailService.__smtp_password,
            use_tls=True,
        )

        return smtp

    @classmethod
    def send_welcome_email(cls, email):

        html_body = EmailTemplateParser.expand(

# Path: nflpool/email/template_parser.py
# class EmailTemplateParser:
#     welcome = None
#     reset_password = None
# 
#     @staticmethod
#     def global_init():
#         templates = os.path.join(os.path.dirname(__file__), "templates")
#         welcome_file = os.path.join(templates, "welcome.html")
#         with open(welcome_file) as fin:
#             EmailTemplateParser.welcome = fin.read()
# 
#         welcome_file = os.path.join(templates, "password_reset.html")
#         with open(welcome_file) as fin:
#             EmailTemplateParser.reset_password = fin.read()
# 
#     @staticmethod
#     def expand(template, data):
# 
#         final_text = template
#         for k in data:
#             key = "{" + k + "}"
#             final_text = final_text.replace(key, data[k])
# 
#         return final_text


# Path: nflpool/services/email_service.py
import mailer
import html2text
from nflpool.email.template_parser import EmailTemplateParser

                From=EmailService.__from_address, To=to_address, charset="utf-8"
            )
            message.Subject = subject
            message.Html = html_body
            message.Body = html2text.html2text(html_body)

            if not EmailService.__is_debug_mode:
                print("Sending message (live!)")
                smtp.send(message)
            else:
                print("Skipping send, email is in dev mode.")
        except Exception as x:
            print("Error sending mail: {}".format(x))

    @staticmethod
    def create_smtp_server():
        smtp = mailer.Mailer(
            host=EmailService.__smtp_server,
            port=EmailService.__smtp_port,
            usr=EmailService.__smtp_username,
            pwd=EmailService.__smtp_password,
            use_tls=True,
        )

        return smtp

    @classmethod
    def send_welcome_email(cls, email):

        html_body = EmailTemplateParser.expand(

            EmailTemplateParser.welcome, {"email": email}