Advertisement
Edosecs

main

Apr 22nd, 2024
744
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 35.37 KB | None | 0 0
  1. import tkinter as tk
  2. from tkinter import ttk
  3. from tkinter import messagebox
  4. from PIL import Image, ImageTk
  5. import requests
  6. from io import BytesIO
  7. from email.mime.multipart import MIMEMultipart
  8. from email.mime.text import MIMEText
  9. import smtplib
  10. from html_templates import stockx_delivered, shipped_to_stockx, verified_and_shipped, nikeen, nikeit, nikesnkrs, adidasit, appleen, farfetchen, zalandoit, zalandoen
  11.  
  12.  
  13. class EmailApp(tk.Tk):
  14.     def __init__(self):
  15.         super().__init__()
  16.         self.info_input_fields = None
  17.         self.image_label = None  # Aggiungi un'etichetta per l'immagine
  18.         self.title("RICETTARIO")
  19.  
  20.         self.notebook = ttk.Notebook(self)
  21.         self.notebook.pack(fill="both", expand=True)
  22.  
  23.         self.type_selection_frame = ttk.Frame(self.notebook)
  24.         self.language_selection_frame = ttk.Frame(self.notebook)
  25.         self.info_input_frame = ttk.Frame(self.notebook)
  26.  
  27.         self.notebook.add(self.type_selection_frame, text="Selezione Tipo HTML")
  28.         self.notebook.add(self.language_selection_frame, text="Selezione Tipologia")
  29.         self.notebook.add(self.info_input_frame, text="Inserimento Informazioni")
  30.  
  31.         # Variabili per memorizzare la selezione del tipo di HTML e l'email del destinatario
  32.         self.selected_html_type = tk.StringVar()
  33.         self.recipient_email = tk.StringVar()
  34.         self.selected_language = tk.StringVar()
  35.  
  36.         # Creazione delle pagine iniziali
  37.         self.create_type_selection_page()
  38.         self.create_language_selection_page()
  39.         self.create_info_input_page()
  40.  
  41.         # Bind dell'evento di cambio scheda
  42.         self.notebook.bind("<<NotebookTabChanged>>", self.on_tab_change)
  43.  
  44.     def create_type_selection_page(self):
  45.         label_html_type = tk.Label(self.type_selection_frame, text="Seleziona Tipo di HTML:")
  46.         label_html_type.grid(row=0, column=0, sticky=tk.W)
  47.  
  48.         html_options = ["StockX", "Nike", "Adidas", "Apple", "Farfetch", "Zalando"]   # Scelte per il tipo di HTML
  49.         html_type_menu = ttk.Combobox(
  50.             self.type_selection_frame, textvariable=self.selected_html_type, values=html_options, state='readonly'
  51.         )
  52.         html_type_menu.grid(row=0, column=1, padx=5, pady=5, sticky=tk.W)
  53.  
  54.         label_email = tk.Label(self.type_selection_frame, text="Inserisci l'Email:")
  55.         label_email.grid(row=1, column=0, sticky=tk.W)
  56.         email_entry = tk.Entry(self.type_selection_frame, textvariable=self.recipient_email)
  57.         email_entry.grid(row=1, column=1, padx=5, pady=5, sticky=tk.W)
  58.  
  59.         confirm_button = tk.Button(self.type_selection_frame, text="Avanti", command=self.show_language_selection_page)
  60.         confirm_button.grid(row=2, columnspan=2, pady=10)
  61.  
  62.     def on_tab_change(self, event):
  63.         current_tab = self.notebook.index(self.notebook.select())
  64.         if current_tab == 1:  # Language Selection Page
  65.             if not self.validate_email() or not self.selected_html_type.get():
  66.                 messagebox.showerror("Errore", "Inserisci un'email valida e seleziona un tipo di HTML.")
  67.                 self.show_type_selection_page()
  68.             else:
  69.                 self.update_language_options()  # Aggiorna le opzioni di lingua
  70.                 self.update_language_image()  # Aggiorna l'immagine
  71.         elif current_tab == 2:  # Info Input Page
  72.             if not self.selected_language.get():
  73.                 messagebox.showerror("Errore", "Seleziona una tipologia prima di procedere.")
  74.                 self.show_language_selection_page()
  75.  
  76.     def update_language_image(self):
  77.         if self.image_label:
  78.             self.image_label.grid_forget()  # Rimuovi l'immagine precedente
  79.  
  80.         image_url = None
  81.         if self.selected_html_type.get() == "StockX":
  82.             image_url = "https://upload.wikimedia.org/wikipedia/commons/9/95/Stockx_logo.png"
  83.         elif self.selected_html_type.get() == "Nike":
  84.             image_url = "https://logos-world.net/wp-content/uploads/2020/04/Nike-Logo.png"
  85.         elif self.selected_html_type.get() == "Adidas":
  86.             image_url = "https://kivasports.net/wp-content/uploads/sites/47/2022/02/adidas-logo2.png"
  87.         elif self.selected_html_type.get() == "Apple":
  88.             image_url = "https://seeklogo.com/images/A/apple-logo-E3DBF3AE34-seeklogo.com.png"
  89.         elif self.selected_html_type.get() == "Farfetch":
  90.             image_url = "https://vin.imgix.net/uploads/provider/63e0e21ad1a8f.png"
  91.         elif self.selected_html_type.get() == "Zalando":
  92.             image_url = "https://cdn.freebiesupply.com/logos/thumbs/2x/zalando-2-logo.png"
  93.  
  94.         if image_url:
  95.             response = requests.get(image_url)
  96.             image = Image.open(BytesIO(response.content))
  97.  
  98.             # Ridimensionare l'immagine se è il logo di Nike
  99.             if self.selected_html_type.get() == "Nike":
  100.                 image = image.resize((300, 155), Image.Resampling.LANCZOS)
  101.             elif self.selected_html_type.get() == "Adidas":
  102.                 image = image.resize((300, 155), Image.Resampling.LANCZOS)
  103.             elif self.selected_html_type.get() == "Apple":
  104.                 image = image.resize((160, 204), Image.Resampling.LANCZOS)
  105.             elif self.selected_html_type == "Farfetch":
  106.                 image = image.resize((300, 155), Image.Resampling.LANCZOS)
  107.             elif self.selected_html_type == "Zalando":
  108.                 image = image.resize((300, 155), Image.Resampling.LANCZOS)
  109.  
  110.             photo_image = ImageTk.PhotoImage(image)
  111.             self.image_label = ttk.Label(self.language_selection_frame, image=photo_image)
  112.             self.image_label.image = photo_image
  113.             self.image_label.grid(row=3, column=0, columnspan=2, pady=10)
  114.  
  115.     def show_type_selection_page(self):
  116.         self.notebook.select(self.type_selection_frame)
  117.  
  118.     def show_language_selection_page(self):
  119.         self.notebook.select(self.language_selection_frame)
  120.  
  121.     def create_language_selection_page(self):
  122.         label_html_type = tk.Label(self.language_selection_frame, text="Tipo di HTML Selezionato:")
  123.         label_html_type.grid(row=0, column=0, sticky=tk.W)
  124.  
  125.         selected_html_label = tk.Label(self.language_selection_frame, textvariable=self.selected_html_type)
  126.         selected_html_label.grid(row=0, column=1, sticky=tk.W)
  127.         label_language = tk.Label(self.language_selection_frame, text="Seleziona Tipologia:")
  128.         label_language.grid(row=1, column=0, sticky=tk.W)
  129.  
  130.         self.language_menu = ttk.Combobox(self.language_selection_frame, textvariable=self.selected_language, state='readonly')
  131.         self.language_menu.grid(row=1, column=1, padx=5, pady=5, sticky=tk.W)
  132.  
  133.         confirm_button = tk.Button(self.language_selection_frame, text="Avanti", command=self.show_info_input_page)
  134.         confirm_button.grid(row=2, columnspan=2, pady=10)
  135.  
  136.     def update_language_options(self):
  137.         html_type = self.selected_html_type.get()
  138.         if html_type == "Nike":
  139.             language_options = ["Ricevuta (EN)", "Ricevuta (IT)", "Sneakers (IT)"]
  140.         elif html_type == "StockX":
  141.             language_options = ["Consegnato (EN)", "Spedito a StockX (IT)", "Verificato e Spedito (IT)"]
  142.         elif html_type == "Adidas":
  143.             language_options = ["Ricevuta (IT)"]
  144.         elif html_type == "Apple":
  145.             language_options = ["Ricevuta (EN)"]
  146.         elif html_type == "Farfetch":
  147.             language_options = ["Ricevuta (EN)"]
  148.         elif html_type == "Zalando":
  149.             language_options = ["Ricevuta (EN)", "Ricevuta (IT)"]
  150.  
  151.         self.language_menu['values'] = language_options
  152.         self.selected_language.set("")  # Clear previous selection
  153.  
  154.     def show_info_input_page(self):
  155.         if self.validate_email() and self.selected_html_type.get() and self.selected_language.get():
  156.             self.notebook.select(self.info_input_frame)
  157.             self.populate_info_input_page()
  158.         else:
  159.             messagebox.showerror("Errore", "Seleziona un tipo di HTML e una lingua e inserisci un'email valida.")
  160.  
  161.     def validate_email(self):
  162.         email = self.recipient_email.get()
  163.         if not email:
  164.             return False
  165.         if "@" in email and "." in email:
  166.             return True
  167.         else:
  168.             return False
  169.  
  170.     def create_info_input_page(self):
  171.         self.info_input_fields = {}
  172.  
  173.     def populate_info_input_page(self):
  174.         for widget in self.info_input_frame.winfo_children():
  175.             widget.grid_forget()
  176.  
  177.         if self.selected_html_type.get() == "StockX":
  178.             if self.selected_language.get() == "Consegnato (EN)":
  179.                 self.create_stockx_delivered_info_input()
  180.             elif self.selected_language.get() == "Spedito a StockX (IT)":
  181.                 self.create_stockx_shipped_to_stockx_info_input()
  182.             elif self.selected_language.get() == "Verificato e Spedito (IT)":
  183.                 self.create_verified_and_shipped_info_input()
  184.         elif self.selected_html_type.get() == "Nike":
  185.             if self.selected_language.get() == "Ricevuta (EN)":
  186.                 self.create_nikeen_info_input()
  187.             elif self.selected_language.get() == "Ricevuta (IT)":
  188.                 self.create_nikeit_info_input()
  189.             elif self.selected_language.get() == "Sneakers (IT)":
  190.                 self.create_nikeit_info_input()
  191.         elif self.selected_html_type.get() == "Adidas":
  192.             if self.selected_language.get() == "Ricevuta (IT)":
  193.                 self.create_adidasit_info_input()
  194.         elif self.selected_html_type.get() == "Apple":
  195.             if self.selected_language.get() == "Ricevuta (EN)":
  196.                 self.create_appleen_info_input()
  197.         elif self.selected_html_type.get() == "Farfetch":
  198.             if self.selected_language.get() == "Ricevuta (EN)":
  199.                 self.create_farfetchen_info_input()
  200.         elif self.selected_html_type.get() == "Zalando":
  201.             if self.selected_language.get() == "Ricevuta (EN)":
  202.                 self.create_zalandoen_info_input()
  203.             elif self.selected_language.get() == "Ricevuta (IT)":
  204.                 self.create_zalandoit_info_input()
  205.  
  206.         back_button = tk.Button(self.info_input_frame, text="Indietro", command=self.show_language_selection_page)
  207.         back_button.grid(row=0, column=0, pady=10)
  208.  
  209.         send_button = tk.Button(self.info_input_frame, text="Invia Email", command=self.send_email)
  210.         send_button.grid(row=0, column=1, pady=10)
  211.  
  212.         restart_button = tk.Button(self.info_input_frame, text="Riavvia", command=self.restart)
  213.         restart_button.grid(row=0, column=2, pady=10)
  214.  
  215.     def restart(self):
  216.         self.destroy()
  217.         EmailApp().mainloop()
  218.  
  219.     def create_stockx_delivered_info_input(self):
  220.         self.info_input_fields = {
  221.             "URL Immagine": None,
  222.             "Data di Consegna": None,
  223.             "Nome Prodotto": None,
  224.             "Size": None,
  225.             "Purchase Price": None,
  226.             "Processing Fee": None,
  227.             "Shipping": None,
  228.             "Total": None
  229.         }
  230.  
  231.         row = 1
  232.         for field_name in self.info_input_fields.keys():
  233.             label = tk.Label(self.info_input_frame, text=field_name + ":")
  234.             label.grid(row=row, column=0, sticky=tk.W)
  235.             entry = tk.Entry(self.info_input_frame)
  236.             entry.grid(row=row, column=1, padx=5, pady=5, sticky=tk.W)
  237.             self.info_input_fields[field_name] = entry
  238.             row += 1
  239.  
  240.     def create_stockx_shipped_to_stockx_info_input(self):
  241.         self.info_input_fields = {
  242.             "URL Immagine": None,
  243.             "Data di Consegna": None,
  244.             "Seconda Data di Consegna": None,
  245.             "Nome Prodotto": None,
  246.             "Size": None,
  247.             "Purchase Price": None,
  248.             "Processing Fee": None,
  249.             "Shipping": None,
  250.             "Total": None
  251.         }
  252.  
  253.         row = 1
  254.         for field_name in self.info_input_fields.keys():
  255.             label = tk.Label(self.info_input_frame, text=field_name + ":")
  256.             label.grid(row=row, column=0, sticky=tk.W)
  257.             entry = tk.Entry(self.info_input_frame)
  258.             entry.grid(row=row, column=1, padx=5, pady=5, sticky=tk.W)
  259.             self.info_input_fields[field_name] = entry
  260.             row += 1
  261.  
  262.     def create_verified_and_shipped_info_input(self):
  263.         self.info_input_fields = {
  264.             "URL Immagine": None,
  265.             "Nome Prodotto": None,
  266.             "Size": None,
  267.             "Purchase Price": None,
  268.             "Processing Fee": None,
  269.             "Shipping": None,
  270.             "Total": None,
  271.         }
  272.  
  273.         row = 1
  274.         for field_name in self.info_input_fields.keys():
  275.             label = tk.Label(self.info_input_frame, text=field_name + ":")
  276.             label.grid(row=row, column=0, sticky=tk.W)
  277.             entry = tk.Entry(self.info_input_frame)
  278.             entry.grid(row=row, column=1, padx=5, pady=5, sticky=tk.W)
  279.             self.info_input_fields[field_name] = entry
  280.             row += 1
  281.  
  282.     def create_nikeen_info_input(self):
  283.         self.info_input_fields = {
  284.             "URL Immagine": None,
  285.             "Data Ordine": None,
  286.             "Data di Consegna": None,
  287.             "Nome Prodotto": None,
  288.             "Size": None,
  289.             "Prezzo Prodotto": None,
  290.             "Nome": None,
  291.             "Cognome": None,
  292.             "Indirizzo": None,
  293.             "Citta": None,
  294.             "Stato": None,
  295.             "CAP": None,
  296.             "Totale": None
  297.         }
  298.  
  299.         row = 1
  300.         for field_name in self.info_input_fields.keys():
  301.             label = tk.Label(self.info_input_frame, text=field_name + ":")
  302.             label.grid(row=row, column=0, sticky=tk.W)
  303.             entry = tk.Entry(self.info_input_frame)
  304.             entry.grid(row=row, column=1, padx=5, pady=5, sticky=tk.W)
  305.             self.info_input_fields[field_name] = entry
  306.             row += 1
  307.  
  308.     def create_nikeit_info_input(self):
  309.         self.info_input_fields = {
  310.             "URL Immagine": None,
  311.             "Data Ordine": None,
  312.             "Data di Consegna": None,
  313.             "Nome Prodotto": None,
  314.             "Size": None,
  315.             "Prezzo Prodotto": None,
  316.             "Nome": None,
  317.             "Cognome": None,
  318.             "Indirizzo": None,
  319.             "Citta": None,
  320.             "Stato": None,
  321.             "CAP": None
  322.         }
  323.  
  324.         row = 1
  325.         for field_name in self.info_input_fields.keys():
  326.             label = tk.Label(self.info_input_frame, text=field_name + ":")
  327.             label.grid(row=row, column=0, sticky=tk.W)
  328.             entry = tk.Entry(self.info_input_frame)
  329.             entry.grid(row=row, column=1, padx=5, pady=5, sticky=tk.W)
  330.             self.info_input_fields[field_name] = entry
  331.             row += 1
  332.  
  333.     def create_nikesnkrs_info_input(self):
  334.         self.info_input_fields = {
  335.             "URL Immagine": None,
  336.             "Data Ordine": None,
  337.             "Data di Consegna": None,
  338.             "Nome Prodotto": None,
  339.             "Size": None,
  340.             "Prezzo Prodotto": None,
  341.             "Nome": None,
  342.             "Cognome": None,
  343.             "Indirizzo": None,
  344.             "Citta": None,
  345.             "Stato": None,
  346.             "CAP": None
  347.         }
  348.  
  349.         row = 1
  350.         for field_name in self.info_input_fields.keys():
  351.             label = tk.Label(self.info_input_frame, text=field_name + ":")
  352.             label.grid(row=row, column=0, sticky=tk.W)
  353.             entry = tk.Entry(self.info_input_frame)
  354.             entry.grid(row=row, column=1, padx=5, pady=5, sticky=tk.W)
  355.             self.info_input_fields[field_name] = entry
  356.             row += 1
  357.  
  358.     def create_adidasit_info_input(self):
  359.         self.info_input_fields = {
  360.             "URL Immagine": None,
  361.             "Data di Consegna": None,
  362.             "Nome Prodotto": None,
  363.             "Size": None,
  364.             "Colore": None,
  365.             "ID Prodotto": None,
  366.             "Prezzo Prodotto": None,
  367.             "Nome": None,
  368.             "Cognome": None,
  369.             "Indirizzo": None,
  370.             "Citta": None,
  371.             "CAP": None
  372.         }
  373.  
  374.         row = 1
  375.         for field_name in self.info_input_fields.keys():
  376.             label = tk.Label(self.info_input_frame, text=field_name + ":")
  377.             label.grid(row=row, column=0, sticky=tk.W)
  378.             entry = tk.Entry(self.info_input_frame)
  379.             entry.grid(row=row, column=1, padx=5, pady=5, sticky=tk.W)
  380.             self.info_input_fields[field_name] = entry
  381.             row += 1
  382.  
  383.     def create_appleen_info_input(self):
  384.         self.info_input_fields = {
  385.             "URL Immagine": None,
  386.             "Data Ordine": None,
  387.             "Nome Prodotto": None,
  388.             "Quantità": None,
  389.             "Prezzo Prodotto": None,
  390.             "Totale": None,
  391.             "Nome": None,
  392.             "Cognome": None,
  393.             "Mail": None,
  394.             "Indirizzo": None,
  395.             "Citta": None,
  396.             "Stato": None,
  397.             "CAP": None
  398.         }
  399.  
  400.         row = 1
  401.         for field_name in self.info_input_fields.keys():
  402.             label = tk.Label(self.info_input_frame, text=field_name + ":")
  403.             label.grid(row=row, column=0, sticky=tk.W)
  404.             entry = tk.Entry(self.info_input_frame)
  405.             entry.grid(row=row, column=1, padx=5, pady=5, sticky=tk.W)
  406.             self.info_input_fields[field_name] = entry
  407.             row += 1
  408.  
  409.     def create_farfetchen_info_input(self):
  410.         self.info_input_fields = {
  411.             "URL Immagine": None,
  412.             "Prima Data Consegna": None,
  413.             "Seconda Data Consegna": None,
  414.             "Numero Ordine [es: 49ZADM]": None,
  415.             "Brand": None,
  416.             "Nome Prodotto": None,
  417.             "Size": None,
  418.             "Prezzo Prodotto": None,
  419.             "Totale [10€ in più al Prezzo]": None,
  420.             "Nome": None,
  421.             "Cognome": None,
  422.             "Indirizzo": None,
  423.             "Citta": None,
  424.             "Stato": None,
  425.             "CAP": None
  426.         }
  427.  
  428.         row = 1
  429.         for field_name in self.info_input_fields.keys():
  430.             label = tk.Label(self.info_input_frame, text=field_name + ":")
  431.             label.grid(row=row, column=0, sticky=tk.W)
  432.             entry = tk.Entry(self.info_input_frame)
  433.             entry.grid(row=row, column=1, padx=5, pady=5, sticky=tk.W)
  434.             self.info_input_fields[field_name] = entry
  435.             row += 1
  436.  
  437.     def create_zalandoen_info_input(self):
  438.         self.info_input_fields = {
  439.             "URL Immagine": None,
  440.             "Data Ordine [Fri, 21 Apr 2023]": None,
  441.             "Prima Data Consegna [Mon, 24 Apr 2023]": None,
  442.             "Seconda Data Consegna [Wed, 26 Apr 2023]": None,
  443.             "Brand": None,
  444.             "Product Name": None,
  445.             "Color": None,
  446.             "Size": None,
  447.             "Price": None,
  448.             "Ship": None,
  449.             "Total": None,
  450.             "Nome": None,
  451.             "Cognome": None,
  452.             "Indirizzo": None,
  453.             "Citta": None,
  454.             "CAP": None
  455.         }
  456.  
  457.         row = 1
  458.         for field_name in self.info_input_fields.keys():
  459.             label = tk.Label(self.info_input_frame, text=field_name + ":")
  460.             label.grid(row=row, column=0, sticky=tk.W)
  461.             entry = tk.Entry(self.info_input_frame)
  462.             entry.grid(row=row, column=1, padx=5, pady=5, sticky=tk.W)
  463.             self.info_input_fields[field_name] = entry
  464.             row += 1
  465.  
  466.     def create_zalandoit_info_input(self):
  467.         self.info_input_fields = {
  468.             "URL Immagine": None,
  469.             "Data Ordine [Ven, 21 Apr 2023]": None,
  470.             "Prima Data Consegna [Lun, 24 Apr 2023]": None,
  471.             "Seconda Data Consegna [Mer, 26 Apr 2023]": None,
  472.             "Brand": None,
  473.             "Nome Prodotto": None,
  474.             "Colore": None,
  475.             "Size": None,
  476.             "Prezzo Prodotto": None,
  477.             "Nome": None,
  478.             "Cognome": None,
  479.             "Indirizzo": None,
  480.             "Citta": None,
  481.             "CAP": None
  482.         }
  483.  
  484.         row = 1
  485.         for field_name in self.info_input_fields.keys():
  486.             label = tk.Label(self.info_input_frame, text=field_name + ":")
  487.             label.grid(row=row, column=0, sticky=tk.W)
  488.             entry = tk.Entry(self.info_input_frame)
  489.             entry.grid(row=row, column=1, padx=5, pady=5, sticky=tk.W)
  490.             self.info_input_fields[field_name] = entry
  491.             row += 1
  492.  
  493.     def send_email(self):
  494.         html_type = self.selected_html_type.get()
  495.         recipient_email = self.recipient_email.get()
  496.  
  497.         if not recipient_email:
  498.             messagebox.showerror("Errore", "Inserisci un'email valida.")
  499.             return
  500.  
  501.         language = self.selected_language.get()
  502.  
  503.         if html_type == "StockX":
  504.             if self.selected_language.get() == "Consegnato (EN)":
  505.                 if not all(self.info_input_fields.values()):
  506.                     messagebox.showerror("Errore", "Inserisci tutti i campi richiesti.")
  507.                     return
  508.             elif self.selected_language.get() == "Spedito a StockX (IT)":
  509.                 if not all(self.info_input_fields.values()):
  510.                     messagebox.showerror("Errore", "Inserisci tutti i campi richiesti.")
  511.                     return
  512.             elif self.selected_language.get() == "Verificato e Spedito (IT)":
  513.                 if not all(self.info_input_fields.values()):
  514.                     messagebox.showerror("Errore", "Inserisci tutti i campi richiesti.")
  515.                     return
  516.         else:
  517.             if not all(field.get() for field in self.info_input_fields.values()):
  518.                 messagebox.showerror("Errore", "Inserisci tutti i campi richiesti.")
  519.                 return
  520.  
  521.         if html_type == "Apple":
  522.             email_subject = self.get_email_subject(html_type, self.info_input_fields["Nome Prodotto"].get(), "", language)
  523.         elif html_type == "Zalando":
  524.             if language == "Ricevuta (EN)":
  525.                 email_subject = self.get_email_subject(html_type, self.info_input_fields["Product Name"].get(), self.info_input_fields["Size"].get(), language)
  526.         else:
  527.             email_subject = self.get_email_subject(html_type, self.info_input_fields["Nome Prodotto"].get(), self.info_input_fields["Size"].get(), language)
  528.  
  529.         if self.send_email_smtp(self.get_html_content(html_type), recipient_email, email_subject, self.selected_html_type.get()):
  530.             messagebox.showinfo("Successo", "Email inviata con successo!")
  531.         else:
  532.             messagebox.showerror("Errore", "Si è verificato un errore durante l'invio dell'email.")
  533.  
  534.     @staticmethod
  535.     def get_email_subject(html_type, product_name, size, language):
  536.         if html_type == "StockX":
  537.             if language == "Consegnato (EN)":
  538.                 return f"🎉 Ordine Consegnato: {product_name} (Taglia {size})"
  539.             elif language == "Spedito a StockX (IT)":
  540.                 return f"📦 L'ordine è stato spedito a StockX: {product_name}"
  541.             elif language == "Verificato e Spedito (IT)":
  542.                 return f"✅ Ordine verificato e spedito: {product_name}"
  543.         elif html_type == "Nike":
  544.             if language == "Ricevuta (EN)":
  545.                 return "Thank You for Your Order (#C13114548220)"
  546.             elif language == "Ricevuta (IT)":
  547.                 return "Abbiamo appena ricevuto il tuo ordine"
  548.             elif language == "Sneakers (IT)":
  549.                 return "Il tuo ordine è stato appena spedito"
  550.         elif html_type == "Adidas":
  551.             if language == "Ricevuta (IT)":
  552.                 return "Abbiamo ricevuto il tuo ordine adidas"
  553.         elif html_type == "Apple":
  554.             if language == "Ricevuta (EN)":
  555.                 return "Stiamo elaborando il tuo ordine W12420393410"
  556.         elif html_type == "Farfetch":
  557.             if language == "Ricevuta (EN)":
  558.                 return "Grazie per il tuo ordine. Ecco cosa puoi aspettarti ora"
  559.         elif html_type == "Zalando":
  560.             if language == "Ricevuta (IT)":
  561.                 return "Grazie per il tuo ordine"
  562.             elif language == "Ricevuta (EN)":
  563.                 return "Thanks for your order"
  564.  
  565.     def get_html_content(self, html_type):
  566.         language = self.selected_language.get()
  567.         if html_type == "StockX":
  568.             if language == "Consegnato (EN)":
  569.                 return stockx_delivered(
  570.                     self.info_input_fields["URL Immagine"].get(),
  571.                     self.info_input_fields["Data di Consegna"].get(),
  572.                     self.info_input_fields["Nome Prodotto"].get(),
  573.                     self.info_input_fields["Size"].get(),
  574.                     self.info_input_fields["Purchase Price"].get(),
  575.                     self.info_input_fields["Processing Fee"].get(),
  576.                     self.info_input_fields["Shipping"].get(),
  577.                     self.info_input_fields["Total"].get()
  578.                 )
  579.             elif language == "Spedito a StockX (IT)":
  580.                 return shipped_to_stockx(
  581.                     self.info_input_fields["URL Immagine"].get(),
  582.                     self.info_input_fields["Data di Consegna"].get(),
  583.                     self.info_input_fields["Seconda Data di Consegna"].get(),
  584.                     self.info_input_fields["Nome Prodotto"].get(),
  585.                     self.info_input_fields["Size"].get(),
  586.                     self.info_input_fields["Purchase Price"].get(),
  587.                     self.info_input_fields["Processing Fee"].get(),
  588.                     self.info_input_fields["Shipping"].get(),
  589.                     self.info_input_fields["Total"].get()
  590.                 )
  591.             elif language == "Verificato e Spedito (IT)":
  592.                 return verified_and_shipped(
  593.                     self.info_input_fields["URL Immagine"].get(),
  594.                     self.info_input_fields["Nome Prodotto"].get(),
  595.                     self.info_input_fields["Size"].get(),
  596.                     self.info_input_fields["Purchase Price"].get(),
  597.                     self.info_input_fields["Processing Fee"].get(),
  598.                     self.info_input_fields["Shipping"].get(),
  599.                     self.info_input_fields["Total"].get()
  600.                 )
  601.         elif html_type == "Nike":
  602.             if language == "Ricevuta (EN)":
  603.                 return nikeen(
  604.                     self.info_input_fields["URL Immagine"].get(),
  605.                     self.info_input_fields["Data Ordine"].get(),
  606.                     self.info_input_fields["Data di Consegna"].get(),
  607.                     self.info_input_fields["Nome Prodotto"].get(),
  608.                     self.info_input_fields["Size"].get(),
  609.                     self.info_input_fields["Prezzo Prodotto"].get(),
  610.                     self.info_input_fields["Nome"].get(),
  611.                     self.info_input_fields["Cognome"].get(),
  612.                     self.info_input_fields["Indirizzo"].get(),
  613.                     self.info_input_fields["Citta"].get(),
  614.                     self.info_input_fields["Stato"].get(),
  615.                     self.info_input_fields["CAP"].get(),
  616.                     self.info_input_fields["Totale"].get()
  617.                 )
  618.             elif language == "Ricevuta (IT)":
  619.                 return nikeit(
  620.                     self.info_input_fields["URL Immagine"].get(),
  621.                     self.info_input_fields["Data Ordine"].get(),
  622.                     self.info_input_fields["Data di Consegna"].get(),
  623.                     self.info_input_fields["Nome Prodotto"].get(),
  624.                     self.info_input_fields["Size"].get(),
  625.                     self.info_input_fields["Prezzo Prodotto"].get(),
  626.                     self.info_input_fields["Nome"].get(),
  627.                     self.info_input_fields["Cognome"].get(),
  628.                     self.info_input_fields["Indirizzo"].get(),
  629.                     self.info_input_fields["Citta"].get(),
  630.                     self.info_input_fields["Stato"].get(),
  631.                     self.info_input_fields["CAP"].get()
  632.                 )
  633.             elif language == "Sneakers (IT)":
  634.                 return nikesnkrs(
  635.                     self.info_input_fields["URL Immagine"].get(),
  636.                     self.info_input_fields["Data Ordine"].get(),
  637.                     self.info_input_fields["Data di Consegna"].get(),
  638.                     self.info_input_fields["Nome Prodotto"].get(),
  639.                     self.info_input_fields["Size"].get(),
  640.                     self.info_input_fields["Prezzo Prodotto"].get(),
  641.                     self.info_input_fields["Nome"].get(),
  642.                     self.info_input_fields["Cognome"].get(),
  643.                     self.info_input_fields["Indirizzo"].get(),
  644.                     self.info_input_fields["Citta"].get(),
  645.                     self.info_input_fields["Stato"].get(),
  646.                     self.info_input_fields["CAP"].get()
  647.                 )
  648.         elif html_type == "Adidas":
  649.             if language == "Ricevuta (IT)":
  650.                 return adidasit(
  651.                     self.info_input_fields["URL Immagine"].get(),
  652.                     self.info_input_fields["Data di Consegna"].get(),
  653.                     self.info_input_fields["Nome Prodotto"].get(),
  654.                     self.info_input_fields["Size"].get(),
  655.                     self.info_input_fields["Colore"].get(),
  656.                     self.info_input_fields["ID Prodotto"].get(),
  657.                     self.info_input_fields["Prezzo Prodotto"].get(),
  658.                     self.info_input_fields["Nome"].get(),
  659.                     self.info_input_fields["Cognome"].get(),
  660.                     self.info_input_fields["Indirizzo"].get(),
  661.                     self.info_input_fields["Citta"].get(),
  662.                     self.info_input_fields["CAP"].get()
  663.                 )
  664.         elif html_type == "Apple":
  665.             if language == "Ricevuta (EN)":
  666.                 return appleen(
  667.                     self.info_input_fields["URL Immagine"].get(),
  668.                     self.info_input_fields["Data Ordine"].get(),
  669.                     self.info_input_fields["Nome Prodotto"].get(),
  670.                     self.info_input_fields["Quantità"].get(),
  671.                     self.info_input_fields["Prezzo Prodotto"].get(),
  672.                     self.info_input_fields["Totale"].get(),
  673.                     self.info_input_fields["Nome"].get(),
  674.                     self.info_input_fields["Cognome"].get(),
  675.                     self.info_input_fields["Mail"].get(),
  676.                     self.info_input_fields["Indirizzo"].get(),
  677.                     self.info_input_fields["Citta"].get(),
  678.                     self.info_input_fields["Stato"].get(),
  679.                     self.info_input_fields["CAP"].get()
  680.                 )
  681.         elif html_type == "Farfetch":
  682.             if language == "Ricevuta (EN)":
  683.                 return farfetchen(
  684.                     self.info_input_fields["URL Immagine"].get(),
  685.                     self.info_input_fields["Prima Data Consegna"].get(),
  686.                     self.info_input_fields["Seconda Data Consegna"].get(),
  687.                     self.info_input_fields["Numero Ordine [es: 49ZADM]"].get(),
  688.                     self.info_input_fields["Brand"].get(),
  689.                     self.info_input_fields["Nome Prodotto"].get(),
  690.                     self.info_input_fields["Size"].get(),
  691.                     self.info_input_fields["Prezzo Prodotto"].get(),
  692.                     self.info_input_fields["Totale [10€ in più al Prezzo]"].get(),
  693.                     self.info_input_fields["Nome"].get(),
  694.                     self.info_input_fields["Cognome"].get(),
  695.                     self.info_input_fields["Indirizzo"].get(),
  696.                     self.info_input_fields["Citta"].get(),
  697.                     self.info_input_fields["Stato"].get(),
  698.                     self.info_input_fields["CAP"].get()
  699.                 )
  700.         elif html_type == "Zalando":
  701.             if language == "Ricevuta (IT)":
  702.                 return zalandoit(
  703.                     self.info_input_fields["URL Immagine"].get(),
  704.                     self.info_input_fields["Data Ordine [Ven, 21 Apr 2023]"].get(),
  705.                     self.info_input_fields["Prima Data Consegna [Lun, 24 Apr 2023]"].get(),
  706.                     self.info_input_fields["Seconda Data Consegna [Mer, 26 Apr 2023]"].get(),
  707.                     self.info_input_fields["Brand"].get(),
  708.                     self.info_input_fields["Nome Prodotto"].get(),
  709.                     self.info_input_fields["Colore"].get(),
  710.                     self.info_input_fields["Size"].get(),
  711.                     self.info_input_fields["Prezzo Prodotto"].get(),
  712.                     self.info_input_fields["Nome"].get(),
  713.                     self.info_input_fields["Cognome"].get(),
  714.                     self.info_input_fields["Indirizzo"].get(),
  715.                     self.info_input_fields["Citta"].get(),
  716.                     self.info_input_fields["CAP"].get()
  717.                 )
  718.             elif language == "Ricevuta (EN)":
  719.                 return zalandoen(
  720.                     self.info_input_fields["URL Immagine"].get(),
  721.                     self.info_input_fields["Data Ordine [Fri, 21 Apr 2023]"].get(),
  722.                     self.info_input_fields["Prima Data Consegna [Mon, 24 Apr 2023]"].get(),
  723.                     self.info_input_fields["Seconda Data Consegna [Wed, 26 Apr 2023]"].get(),
  724.                     self.info_input_fields["Brand"].get(),
  725.                     self.info_input_fields["Product Name"].get(),
  726.                     self.info_input_fields["Color"].get(),
  727.                     self.info_input_fields["Size"].get(),
  728.                     self.info_input_fields["Price"].get(),
  729.                     self.info_input_fields["Ship"].get(),
  730.                     self.info_input_fields["Total"].get(),
  731.                     self.info_input_fields["Nome"].get(),
  732.                     self.info_input_fields["Cognome"].get(),
  733.                     self.info_input_fields["Indirizzo"].get(),
  734.                     self.info_input_fields["Citta"].get(),
  735.                     self.info_input_fields["CAP"].get()
  736.                 )
  737.  
  738.  
  739.     @staticmethod
  740.     def send_email_smtp(html_content, recipient_email, email_subject, selected_html_type):
  741.         try:
  742.             smtp_server = "smtp.gmail.com"
  743.             smtp_port = 587
  744.             sender_email = "italianricette@gmail.com"
  745.             sender_password = "jcnc dmte hxaj htue"
  746.  
  747.             if selected_html_type == "StockX":
  748.                 sender_name = "StockX"
  749.             elif selected_html_type == "Nike":
  750.                 sender_name = "Nike"
  751.             elif selected_html_type == "Adidas":
  752.                 sender_name = "Adidas"
  753.             elif selected_html_type == "Apple":
  754.                 sender_name = "Apple"
  755.             elif selected_html_type == "Farfetch":
  756.                 sender_name = "Farfetch"
  757.             elif selected_html_type == "Zalando":
  758.                 sender_name = "Zalando"
  759.  
  760.             message = MIMEMultipart()
  761.             message['From'] = f"{sender_name} <{sender_email}>"
  762.             message['To'] = recipient_email
  763.             message['Subject'] = email_subject
  764.  
  765.             message.attach(MIMEText(html_content, 'html'))
  766.  
  767.             server = smtplib.SMTP(smtp_server, smtp_port)
  768.             server.starttls()
  769.             server.login(sender_email, sender_password)
  770.  
  771.             server.sendmail(sender_email, recipient_email, message.as_string())
  772.             server.quit()
  773.  
  774.             return True
  775.         except Exception as e:
  776.             print("Errore durante l'invio dell'email:", e)
  777.             return False
  778.  
  779.  
  780. def main():
  781.     app = EmailApp()
  782.     app.mainloop()
  783.  
  784.  
  785. if __name__ == "__main__":
  786.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement