0% found this document useful (0 votes)
4 views14 pages

EmailValidation - Copie

The document outlines a Python class for sending email validation messages using SMTP. It includes methods for connecting to an SMTP server, generating a random validation code, and constructing an HTML email with a partner's name and icon. The email is designed to confirm validation with a visually appealing layout and includes a thank you message.

Uploaded by

devfeuze132
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views14 pages

EmailValidation - Copie

The document outlines a Python class for sending email validation messages using SMTP. It includes methods for connecting to an SMTP server, generating a random validation code, and constructing an HTML email with a partner's name and icon. The email is designed to confirm validation with a visually appealing layout and includes a thank you message.

Uploaded by

devfeuze132
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 14

DDf000123@

mport smtplib
import random
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from Config.app import expéditeur, mot_de_passe
from Service.UserServices import UserService
from tkinter import messagebox
from email.mime.image import MIMEImage
from Controller.UserController import UserController

class EmailValidation:
def __init__(self):
self.smtp_server = 'smtp.gmail.com' # Remplacez par votre serveur SMTP
self.smtp_port = 587 # Port SMTP (peut varier selon la configuration)
self.model = UserService()

self.model_user = UserController()

def connect(self, id, name_email, destinataire_email):

resultat_idPAtrner = self.model_user.Get_IdPArtner_By_IdUser(id)
namePartner = resultat_idPAtrner["NAME"]
iconPartner = resultat_idPAtrner["ICON"]

# Générer un code de 5 chiffres aléatoires


code = ''.join(random.choices('0123456789', k=6))

# Création de l'e-mail
msg = MIMEMultipart('alternative')
msg['From'] = namePartner
msg['To'] = destinataire_email
msg['Subject'] = 'Validation Confirmation'

# Ajout de l'icône dans le texte de l'e-mail


if iconPartner:
# Création d'une balise HTML pour l'image
image_tag = '<img align="center" border="0" src="cid:icon_image"
alt="Image" title="Image" style="outline: none;text-decoration: none;-ms-
interpolation-mode: bicubic;clear: both;display: inline-block !important;border:
none;height: auto;float: none;width: 32%;max-width: 179.2px;" width="179.2" >'

# Corps du message HTML


html = """
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-
microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="x-apple-disable-message-reformatting">
<!--[if !mso]><!-->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--<![endif]-->
<title></title>
<!--[if !mso]><!-->
<link href="https://fonts.googleapis.com/css?family=Cabin:400,700"
rel="stylesheet" type="text/css">
<!--<![endif]-->

</head>

<body class="clean-body u_body"


style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-
color: #f9f9f9;color: #000000">
<!--[if IE]><div class="ie-container"><![endif]-->
<!--[if mso]><div class="mso-container"><![endif]-->
<table id="u_body"
style="border-collapse: collapse;table-layout: fixed;border-
spacing: 0;vertical-align: top;min-width: 320px;Margin: 0 auto;background-color:
#f9f9f9;width:100%"
cellpadding="0" cellspacing="0">
<tbody>
<tr style="vertical-align: top">
<td style="word-break: break-word;border-collapse: collapse !
important;vertical-align: top">
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0"
cellspacing="0" border="0"><tr><td align="center" style="background-color:
#f9f9f9;"><![endif]-->

<div class="u-row-container" style="padding: 0px;background-


color: transparent">
<div class="u-row"
style="margin: 0 auto;min-width: 320px;max-width:
600px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-
word;background-color: transparent;">
<div
style="border-collapse: collapse;display: table;width:
100%;height: 100%;background-color: transparent;">
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0"
cellspacing="0" border="0"><tr><td style="padding: 0px;background-color:
transparent;" align="center"><table cellpadding="0" cellspacing="0" border="0"
style="width:600px;"><tr style="background-color: transparent;"><![endif]-->

<!--[if (mso)|(IE)]><td align="center" width="600"


style="width: 600px;padding: 0px;border-top: 0px solid transparent;border-left: 0px
solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid
transparent;" valign="top"><![endif]-->
<div class="u-col u-col-100"
style="max-width: 320px;min-width: 600px;display:
table-cell;vertical-align: top;">
<div style="height: 100%;width: 100% !important;">
<!--[if (!mso)&(!IE)]><!-->
<div
style="box-sizing: border-box; height: 100%;
padding: 0px;border-top: 0px solid transparent;border-left: 0px solid
transparent;border-right: 0px solid transparent;border-bottom: 0px solid
transparent;">
<!--<![endif]-->
<table style="font-family:'Cabin',sans-serif;"
role="presentation" cellpadding="0" cellspacing="0"
width="100%" border="0">
<tbody>
<tr>
<td
style="overflow-wrap:break-word;word-
break:break-word;padding:10px;font-family:'Cabin',sans-serif;"
align="left">

<div
style="font-size: 14px; color: #afb0c7;
line-height: 170%; text-align: center; word-wrap: break-word;">
<p style="font-size: 14px; line-height:
170%;"><span
style="font-size: 14px; line-
height: 23.8px;">You Think We Do!</span></p>
</div>

</td>
</tr>
</tbody>
</table>

<!--[if (!mso)&(!IE)]><!-->
</div>
<!--<![endif]-->
</div>
</div>
<!--[if (mso)|(IE)]></td><![endif]-->
<!--[if (mso)|(IE)]></tr></table></td></tr></table><!
[endif]-->
</div>
</div>
</div>

<div class="u-row-container" style="padding: 0px;background-


color: transparent">
<div class="u-row"
style="margin: 0 auto;min-width: 320px;max-width:
600px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-
word;background-color: #ffffff;">
<div
style="border-collapse: collapse;display: table;width:
100%;height: 100%;background-color: transparent;">
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0"
cellspacing="0" border="0"><tr><td style="padding: 0px;background-color:
transparent;" align="center"><table cellpadding="0" cellspacing="0" border="0"
style="width:600px;"><tr style="background-color: #ffffff;"><![endif]-->

<!--[if (mso)|(IE)]><td align="center" width="600"


style="width: 600px;padding: 0px;border-top: 0px solid transparent;border-left: 0px
solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid
transparent;" valign="top"><![endif]-->
<div class="u-col u-col-100"
style="max-width: 320px;min-width: 600px;display:
table-cell;vertical-align: top;">
<div style="height: 100%;width: 100% !important;">
<!--[if (!mso)&(!IE)]><!-->
<div
style="box-sizing: border-box; height: 100%;
padding: 0px;border-top: 0px solid transparent;border-left: 0px solid
transparent;border-right: 0px solid transparent;border-bottom: 0px solid
transparent;">
<!--<![endif]-->

<table style="font-family:'Cabin',sans-serif;"
role="presentation" cellpadding="0" cellspacing="0"
width="100%" border="0">
<tbody>
<tr>
<td
style="overflow-wrap:break-word;word-
break:break-word;padding:20px;font-family:'Cabin',sans-serif;"
align="left">

<table width="100%" cellpadding="0"


cellspacing="0" border="0">
<tr>
<td style="padding-right: 0px;padding-
left: 0px;" align="center">

{}

</td>
</tr>
</table>

</td>
</tr>
</tbody>
</table>

<!--[if (!mso)&(!IE)]><!-->
</div>
<!--<![endif]-->
</div>
</div>
<!--[if (mso)|(IE)]></td><![endif]-->
<!--[if (mso)|(IE)]></tr></table></td></tr></table><!
[endif]-->
</div>
</div>
</div>

<div class="u-row-container" style="padding: 0px;background-


color: transparent">
<div class="u-row"
style="margin: 0 auto;min-width: 320px;max-width:
600px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-
word;background-color: #003399;">
<div
style="border-collapse: collapse;display: table;width:
100%;height: 100%;background-color: transparent;">
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0"
cellspacing="0" border="0"><tr><td style="padding: 0px;background-color:
transparent;" align="center"><table cellpadding="0" cellspacing="0" border="0"
style="width:600px;"><tr style="background-color: #003399;"><![endif]-->

<!--[if (mso)|(IE)]><td align="center" width="600"


style="width: 600px;padding: 0px;border-top: 0px solid transparent;border-left: 0px
solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid
transparent;" valign="top"><![endif]-->
<div class="u-col u-col-100"
style="max-width: 320px;min-width: 600px;display:
table-cell;vertical-align: top;">
<div style="height: 100%;width: 100% !important;">
<!--[if (!mso)&(!IE)]><!-->
<div
style="box-sizing: border-box; height: 100%;
padding: 0px;border-top: 0px solid transparent;border-left: 0px solid
transparent;border-right: 0px solid transparent;border-bottom: 0px solid
transparent;">
<!--<![endif]-->

<table style="font-family:'Cabin',sans-serif;"
role="presentation" cellpadding="0" cellspacing="0"
width="100%" border="0">
<tbody>
<tr>
<td
style="overflow-wrap:break-word;word-
break:break-word;padding:40px 10px 10px;font-family:'Cabin',sans-serif;"
align="left">

<table width="100%" cellpadding="0"


cellspacing="0" border="0">
<tr>
<td style="padding-right: 0px;padding-
left: 0px;" align="center">

<img align="center" border="0"

src="https://cdn.templates.unlayer.com/assets/1597218650916-xxxxc.png" alt="Image"
title="Image"
style="outline: none;text-
decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: inline-
block !important;border: none;height: auto;float: none;width: 26%;max-width:
150.8px;"
width="150.8" />

</td>
</tr>
</table>

</td>
</tr>
</tbody>
</table>

<table style="font-family:'Cabin',sans-serif;"
role="presentation" cellpadding="0" cellspacing="0"
width="100%" border="0">
<tbody>
<tr>
<td
style="overflow-wrap:break-word;word-
break:break-word;padding:10px;font-family:'Cabin',sans-serif;"
align="left">

<div
style="font-size: 14px; color: #e5eaf5;
line-height: 140%; text-align: center; word-wrap: break-word;">
<p style="font-size: 14px; line-height:
140%;"><strong>T H A N K S&nbsp; &nbsp;F O
R&nbsp; &nbsp;S I G N I N G&nbsp;
&nbsp;U P !</strong></p>
</div>

</td>
</tr>
</tbody>
</table>

<table style="font-family:'Cabin',sans-serif;"
role="presentation" cellpadding="0" cellspacing="0"
width="100%" border="0">
<tbody>
<tr>
<td
style="overflow-wrap:break-word;word-
break:break-word;padding:0px 10px 31px;font-family:'Cabin',sans-serif;"
align="left">

<div
style="font-size: 14px; color: #e5eaf5;
line-height: 140%; text-align: center; word-wrap: break-word;">
<p style="font-size: 14px; line-height:
140%;"><span
style="font-size: 28px; line-
height: 39.2px;"><strong><span
style="line-height: 39.2px;
font-size: 28px;">Validation Code</span></strong>
</span>
</p>
</div>

</td>
</tr>
</tbody>
</table>

<!--[if (!mso)&(!IE)]><!-->
</div>
<!--<![endif]-->
</div>
</div>
<!--[if (mso)|(IE)]></td><![endif]-->
<!--[if (mso)|(IE)]></tr></table></td></tr></table><!
[endif]-->
</div>
</div>
</div>

<div class="u-row-container" style="padding: 0px;background-


color: transparent">
<div class="u-row"
style="margin: 0 auto;min-width: 320px;max-width:
600px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-
word;background-color: #ffffff;">
<div
style="border-collapse: collapse;display: table;width:
100%;height: 100%;background-color: transparent;">
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0"
cellspacing="0" border="0"><tr><td style="padding: 0px;background-color:
transparent;" align="center"><table cellpadding="0" cellspacing="0" border="0"
style="width:600px;"><tr style="background-color: #ffffff;"><![endif]-->

<!--[if (mso)|(IE)]><td align="center" width="600"


style="width: 600px;padding: 0px;border-top: 0px solid transparent;border-left: 0px
solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid
transparent;" valign="top"><![endif]-->
<div class="u-col u-col-100"
style="max-width: 320px;min-width: 600px;display:
table-cell;vertical-align: top;">
<div style="height: 100%;width: 100% !important;">
<!--[if (!mso)&(!IE)]><!-->
<div
style="box-sizing: border-box; height: 100%;
padding: 0px;border-top: 0px solid transparent;border-left: 0px solid
transparent;border-right: 0px solid transparent;border-bottom: 0px solid
transparent;">
<!--<![endif]-->

<table style="font-family:'Cabin',sans-serif;"
role="presentation" cellpadding="0" cellspacing="0"
width="100%" border="0">
<tbody>
<tr>
<td
style="overflow-wrap:break-word;word-
break:break-word;padding:33px 55px;font-family:'Cabin',sans-serif;"
align="left">

<div
style="font-size: 14px; line-height:
160%; text-align: center; word-wrap: break-word;">
<p style="font-size: 14px; line-height:
160%;"><span
style="font-size: 22px; line-
height: 35.2px;">Hi, </span></p>
<p style="font-size: 14px; line-height:
160%;"><span
style="font-size: 18px; line-
height: 28.8px;">You're almost ready to begin. Here is
your {} SARL, {} validation code.
Please keep this code
confidential!</span></p>
</div>

</td>
</tr>
</tbody>
</table>
<table style="font-family:'Cabin',sans-serif;"
role="presentation" cellpadding="0" cellspacing="0"
width="100%" border="0">
<tbody>
<tr>
<td
style="overflow-wrap:break-word;word-
break:break-word;padding:10px;font-family:'Cabin',sans-serif;"
align="left">

<div align="center">
<!--[if mso]><v:roundrect
xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-
com:office:word" href="" style="height:46px; v-text-anchor:middle; width:162px;"
arcsize="8.5%" stroke="f" fillcolor="#ff6600"><w:anchorlock/><center
style="color:#FFFFFF;"><![endif]-->
<a href="" target="_blank" class="v-
button"
style="box-sizing: border-box;display:
inline-block;text-decoration: none;-webkit-text-size-adjust: none;text-align:
center;color: #FFFFFF; background-color: #ff6600; border-radius: 4px;-webkit-
border-radius: 4px; -moz-border-radius: 4px; width:auto; max-width:100%; overflow-
wrap: break-word; word-break: break-word; word-wrap:break-word;font-size: 14px;">
<span style="display:block;padding:14px
44px 13px;line-height:120%;"><span
style="font-size: 16px; line-
height: 19.2px;"><strong><span
style="line-height: 19.2px;
font-size: 16px;"> {} </span></strong>
</span>
</span>
</a>
<!--[if mso]></center></v:roundrect><!
[endif]-->
</div>

</td>
</tr>
</tbody>
</table>

<!--[if (!mso)&(!IE)]><!-->
</div>
<!--<![endif]-->
</div>
</div>
<!--[if (mso)|(IE)]></td><![endif]-->
<!--[if (mso)|(IE)]></tr></table></td></tr></table><!
[endif]-->
</div>
</div>
</div>

<div class="u-row-container" style="padding: 0px;background-


color: transparent">
<div class="u-row"
style="margin: 0 auto;min-width: 320px;max-width:
600px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-
word;background-color: #e5eaf5;">
<div
style="border-collapse: collapse;display: table;width:
100%;height: 100%;background-color: transparent;">
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0"
cellspacing="0" border="0"><tr><td style="padding: 0px;background-color:
transparent;" align="center"><table cellpadding="0" cellspacing="0" border="0"
style="width:600px;"><tr style="background-color: #e5eaf5;"><![endif]-->

<!--[if (mso)|(IE)]><td align="center" width="600"


style="width: 600px;padding: 0px;border-top: 0px solid transparent;border-left: 0px
solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid
transparent;" valign="top"><![endif]-->
<div class="u-col u-col-100"
style="max-width: 320px;min-width: 600px;display:
table-cell;vertical-align: top;">
<div style="height: 100%;width: 100% !important;">
<!--[if (!mso)&(!IE)]><!-->
<div
style="box-sizing: border-box; height: 100%;
padding: 0px;border-top: 0px solid transparent;border-left: 0px solid
transparent;border-right: 0px solid transparent;border-bottom: 0px solid
transparent;">
<!--<![endif]-->

<table style="font-family:'Cabin',sans-serif;"
role="presentation" cellpadding="0" cellspacing="0"
width="100%" border="0">
<tbody>
<tr>
<td
style="overflow-wrap:break-word;word-
break:break-word;padding:41px 55px 18px;font-family:'Cabin',sans-serif;"
align="left">

<div
style="font-size: 14px; color: #003399;
line-height: 160%; text-align: center; word-wrap: break-word;">
<p style="font-size: 14px; line-height:
160%;"><span
style="font-size: 20px; line-
height: 32px;"><strong>For More
Information</strong></span></p>
<p style="font-size: 14px; line-height:
160%;"><span
style="font-size: 16px; line-
height: 25.6px; color: #000000;">Never share your passwords and validation codes
with anyone.
Malicious people could use it to
harm you.</span></p>
<p style="font-size: 14px; line-height:
160%;"><span
style="font-size: 16px; line-
height: 25.6px; color: #000000;">+237 233 478 155 / 652
423 486</span></p>
<p style="font-size: 14px; line-height:
160%;"><span
style="font-size: 16px; line-
height: 25.6px; color: #000000;">www.standardallemand.com</span>
</p>
</div>

</td>
</tr>
</tbody>
</table>

<table style="font-family:'Cabin',sans-serif;"
role="presentation" cellpadding="0" cellspacing="0"
width="100%" border="0">
<tbody>
<tr>
<td
style="overflow-wrap:break-word;word-
break:break-word;padding:10px 10px 33px;font-family:'Cabin',sans-serif;"
align="left">

<div align="center">
<div style="display: table; max-
width:146px;">
<!--[if (mso)|(IE)]><table width="146"
cellpadding="0" cellspacing="0" border="0"><tr><td style="border-
collapse:collapse;" align="center"><table width="100%" cellpadding="0"
cellspacing="0" border="0" style="border-collapse:collapse; mso-table-lspace:
0pt;mso-table-rspace: 0pt; width:146px;"><tr><![endif]-->

<!--[if (mso)|(IE)]><td width="32"


style="width:32px; padding-right: 17px;" valign="top"><![endif]-->
<table align="left" border="0"
cellspacing="0" cellpadding="0" width="32" height="32"
style="width: 32px !
important;height: 32px !important;display: inline-block;border-collapse:
collapse;table-layout: fixed;border-spacing: 0;vertical-align: top;margin-right:
17px">
<tbody>
<tr style="vertical-align: top">
<td align="left"
valign="middle"
style="word-break: break-
word;border-collapse: collapse !important;vertical-align: top">
<a href="https://facebook.com/"
title="Facebook" target="_blank">
<img

src="https://cdn.tools.unlayer.com/social/icons/circle-black/facebook.png"
alt="Facebook"
title="Facebook" width="32"
style="outline: none;text-
decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: block !
important;border: none;height: auto;float: none;max-width: 32px !important">
</a>
</td>
</tr>
</tbody>
</table>
<!--[if (mso)|(IE)]></td><![endif]-->
<!--[if (mso)|(IE)]><td width="32"
style="width:32px; padding-right: 17px;" valign="top"><![endif]-->
<table align="left" border="0"
cellspacing="0" cellpadding="0" width="32" height="32"
style="width: 32px !
important;height: 32px !important;display: inline-block;border-collapse:
collapse;table-layout: fixed;border-spacing: 0;vertical-align: top;margin-right:
17px">
<tbody>
<tr style="vertical-align: top">
<td align="left"
valign="middle"
style="word-break: break-
word;border-collapse: collapse !important;vertical-align: top">
<a href="https://linkedin.com/"
title="LinkedIn" target="_blank">
<img

src="https://cdn.tools.unlayer.com/social/icons/circle-black/linkedin.png"
alt="LinkedIn"
title="LinkedIn" width="32"
style="outline: none;text-
decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: block !
important;border: none;height: auto;float: none;max-width: 32px !important">
</a>
</td>
</tr>
</tbody>
</table>
<!--[if (mso)|(IE)]></td><![endif]-->

<!--[if (mso)|(IE)]><td width="32"


style="width:32px; padding-right: 0px;" valign="top"><![endif]-->
<table align="left" border="0"
cellspacing="0" cellpadding="0" width="32" height="32"
style="width: 32px !
important;height: 32px !important;display: inline-block;border-collapse:
collapse;table-layout: fixed;border-spacing: 0;vertical-align: top;margin-right:
0px">
<tbody>
<tr style="vertical-align: top">
<td align="left"
valign="middle"
style="word-break: break-
word;border-collapse: collapse !important;vertical-align: top">
<a
href="https://[email protected]/" title="Email" target="_blank">
<img
src="https://cdn.tools.unlayer.com/social/icons/circle-black/email.png"
alt="Email" title="Email"
width="32"
style="outline: none;text-
decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: block !
important;border: none;height: auto;float: none;max-width: 32px !important">
</a>
</td>
</tr>
</tbody>
</table>
<!--[if (mso)|(IE)]></td><![endif]-->

<!--[if
(mso)|(IE)]></tr></table></td></tr></table><![endif]-->
</div>
</div>

</td>
</tr>
</tbody>
</table>

<!--[if (!mso)&(!IE)]><!-->
</div>
<!--<![endif]-->
</div>
</div>
<!--[if (mso)|(IE)]></td><![endif]-->
<!--[if (mso)|(IE)]></tr></table></td></tr></table><!
[endif]-->
</div>
</div>
</div>

<div class="u-row-container" style="padding: 0px;background-


color: transparent">
<div class="u-row"
style="margin: 0 auto;min-width: 320px;max-width:
600px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-
word;background-color: #003399;">
<div
style="border-collapse: collapse;display: table;width:
100%;height: 100%;background-color: transparent;">
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0"
cellspacing="0" border="0"><tr><td style="padding: 0px;background-color:
transparent;" align="center"><table cellpadding="0" cellspacing="0" border="0"
style="width:600px;"><tr style="background-color: #003399;"><![endif]-->

<!--[if (mso)|(IE)]><td align="center" width="600"


style="width: 600px;padding: 0px;border-top: 0px solid transparent;border-left: 0px
solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid
transparent;" valign="top"><![endif]-->
<div class="u-col u-col-100"
style="max-width: 320px;min-width: 600px;display:
table-cell;vertical-align: top;">
<div style="height: 100%;width: 100% !important;">
<!--[if (!mso)&(!IE)]><!-->
<div
style="box-sizing: border-box; height: 100%;
padding: 0px;border-top: 0px solid transparent;border-left: 0px solid
transparent;border-right: 0px solid transparent;border-bottom: 0px solid
transparent;">
<!--<![endif]-->

<table style="font-family:'Cabin',sans-serif;"
role="presentation" cellpadding="0" cellspacing="0"
width="100%" border="0">
<tbody>
<tr>
<td
style="overflow-wrap:break-word;word-
break:break-word;padding:10px;font-family:'Cabin',sans-serif;"
align="left">

<div
style="font-size: 14px; color: #fafafa;
line-height: 180%; text-align: center; word-wrap: break-word;">
<p style="font-size: 14px; line-height:
180%;"><span
style="font-size: 16px; line-
height: 28.8px;">Copyrights © STANDARD ALLEMAND SARL .All Rights
Reserved</span></p>
</div>

</td>
</tr>
</tbody>
</table>

<!--[if (!mso)&(!IE)]><!-->
</div>
<!--<![endif]-->
</div>
</div>
<!--[if (mso)|(IE)]></td><![endif]-->
<!--[if (mso)|(IE)]></tr></table></td></tr></table><!
[endif]-->
</div>
</div>
</div>

<!--[if (mso)|(IE)]></td></tr></table><![endif]-->
</td>
</tr>
</tbody>
</table>
<!--[if mso]></div><![endif]-->
<!--[if IE]></div><![endif]-->
</body>

</html>
""".format(image_tag, namePartner, name_email, code)

# Ajout du contenu HTML au message


msg.attach(MIMEText(html, 'html'))

# Ajout de l'icône en tant que pièce jointe


if iconPartner:
icon_part = MIMEImage(iconPartner)
icon_part.add_header('Content-ID', '<icon_image>') # Identifiant de
l'image pour l'incorporer dans le texte
msg.attach(icon_part)

# Connexion au serveur SMTP et envoi de l'e-mail


with smtplib.SMTP(self.smtp_server, self.smtp_port) as server:
server.starttls()
server.login(expéditeur, mot_de_passe)
server.sendmail(expéditeur, destinataire_email, msg.as_string())

verif = self.model.add_code(id, destinataire_email, code)

You might also like