import json
import smtplib
import ssl
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from string import Template


class EmailCustomer:
    def __init__(self, customer_email, tracking_number, customer_name):
        self.tracking_number = tracking_number
        self.customer_email = customer_email
        self.customer_name = customer_name
        self.text_message = (
            f"\nHi {customer_name},\n"
            f"Thank you for your Chikfu order! It will be shipped shortly.\n"
            f"Your tracking number is {self.tracking_number}.\n"
            f"You can track your order here: https://www2.lso.com/access/package-tracking\n"
            f"Best,\n"
            f"The Chikfu Team"
        )
        with open("email_customer/email_template.html", "r") as file:
            html_message = file.read()
        template = Template(html_message)
        self.html_message = template.substitute(
            tracking_number=self.tracking_number, customer_name=self.customer_name
        )

    def send_mail(self):
        # initialize server
        context = ssl.create_default_context()
        server = smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context)
        with open("env_variables.json", "r") as file:
            env_variables = json.loads(file.read())
        # pulling username and password from config file
        username = env_variables["EmailUsername"]
        password = env_variables["EmailPassword"]
        # logging into server
        server.login(username, password)
        message = MIMEMultipart("alternative")
        message["Subject"] = "Your Chikfu Order"
        message["From"] = username
        message["To"] = self.customer_email
        # adding in both plain text and html options in cases where email clients do not support html email
        part1 = MIMEText(self.text_message, "plain")
        part2 = MIMEText(self.html_message, "html")
        message.attach(part1)
        message.attach(part2)
        # sending email
        server.sendmail(username, self.customer_email, message.as_string())

49af85004d5b37078ec6ec8150a18f718ebf30ed
<mask token>

<mask token>


class EmailCustomer:

    def __init__(self, customer_email, tracking_number, customer_name):
        self.tracking_number = tracking_number
        self.customer_email = customer_email
        self.customer_name = customer_name
        self.text_message = f"""
Hi {customer_name},
Thank you for your Chikfu order! It will be shipped shortly.
Your tracking number is {self.tracking_number}.
You can track your order here: https://www2.lso.com/access/package-tracking
Best,
The Chikfu Team"""
        with open('email_customer/email_template.html', 'r') as file:
            html_message = file.read()
        template = Template(html_message)
        self.html_message = template.substitute(tracking_number=self.
            tracking_number, customer_name=self.customer_name)
    <mask token>

<mask token>


class EmailCustomer:

    def __init__(self, customer_email, tracking_number, customer_name):
        self.tracking_number = tracking_number
        self.customer_email = customer_email
        self.customer_name = customer_name
        self.text_message = f"""
Hi {customer_name},
Thank you for your Chikfu order! It will be shipped shortly.
Your tracking number is {self.tracking_number}.
You can track your order here: https://www2.lso.com/access/package-tracking
Best,
The Chikfu Team"""
        with open('email_customer/email_template.html', 'r') as file:
            html_message = file.read()
        template = Template(html_message)
        self.html_message = template.substitute(tracking_number=self.
            tracking_number, customer_name=self.customer_name)

    def send_mail(self):
        context = ssl.create_default_context()
        server = smtplib.SMTP_SSL('smtp.gmail.com', 465, context=context)
        with open('env_variables.json', 'r') as file:
            env_variables = json.loads(file.read())
        username = env_variables['EmailUsername']
        password = env_variables['EmailPassword']
        server.login(username, password)
        message = MIMEMultipart('alternative')
        message['Subject'] = 'Your Chikfu Order'
        message['From'] = username
        message['To'] = self.customer_email
        part1 = MIMEText(self.text_message, 'plain')
        part2 = MIMEText(self.html_message, 'html')
        message.attach(part1)
        message.attach(part2)
        server.sendmail(username, self.customer_email, message.as_string())

import json
import smtplib
import ssl
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from string import Template


class EmailCustomer:

    def __init__(self, customer_email, tracking_number, customer_name):
        self.tracking_number = tracking_number
        self.customer_email = customer_email
        self.customer_name = customer_name
        self.text_message = f"""
Hi {customer_name},
Thank you for your Chikfu order! It will be shipped shortly.
Your tracking number is {self.tracking_number}.
You can track your order here: https://www2.lso.com/access/package-tracking
Best,
The Chikfu Team"""
        with open('email_customer/email_template.html', 'r') as file:
            html_message = file.read()
        template = Template(html_message)
        self.html_message = template.substitute(tracking_number=self.
            tracking_number, customer_name=self.customer_name)

    def send_mail(self):
        context = ssl.create_default_context()
        server = smtplib.SMTP_SSL('smtp.gmail.com', 465, context=context)
        with open('env_variables.json', 'r') as file:
            env_variables = json.loads(file.read())
        username = env_variables['EmailUsername']
        password = env_variables['EmailPassword']
        server.login(username, password)
        message = MIMEMultipart('alternative')
        message['Subject'] = 'Your Chikfu Order'
        message['From'] = username
        message['To'] = self.customer_email
        part1 = MIMEText(self.text_message, 'plain')
        part2 = MIMEText(self.html_message, 'html')
        message.attach(part1)
        message.attach(part2)
        server.sendmail(username, self.customer_email, message.as_string())

import json
import smtplib
import ssl
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from string import Template


class EmailCustomer:
    def __init__(self, customer_email, tracking_number, customer_name):
        self.tracking_number = tracking_number
        self.customer_email = customer_email
        self.customer_name = customer_name
        self.text_message = (
            f"\nHi {customer_name},\n"
            f"Thank you for your Chikfu order! It will be shipped shortly.\n"
            f"Your tracking number is {self.tracking_number}.\n"
            f"You can track your order here: https://www2.lso.com/access/package-tracking\n"
            f"Best,\n"
            f"The Chikfu Team"
        )
        with open("email_customer/email_template.html", "r") as file:
            html_message = file.read()
        template = Template(html_message)
        self.html_message = template.substitute(
            tracking_number=self.tracking_number, customer_name=self.customer_name
        )

    def send_mail(self):
        # initialize server
        context = ssl.create_default_context()
        server = smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context)
        with open("env_variables.json", "r") as file:
            env_variables = json.loads(file.read())
        # pulling username and password from config file
        username = env_variables["EmailUsername"]
        password = env_variables["EmailPassword"]
        # logging into server
        server.login(username, password)
        message = MIMEMultipart("alternative")
        message["Subject"] = "Your Chikfu Order"
        message["From"] = username
        message["To"] = self.customer_email
        # adding in both plain text and html options in cases where email clients do not support html email
        part1 = MIMEText(self.text_message, "plain")
        part2 = MIMEText(self.html_message, "html")
        message.attach(part1)
        message.attach(part2)
        # sending email
        server.sendmail(username, self.customer_email, message.as_string())
