29/10/22 - 17h30

master
cherif 2022-10-29 17:50:42 +02:00
parent dadb04b549
commit ee057b2dd5
6 changed files with 2510 additions and 228 deletions

View File

@ -199,4 +199,13 @@ DEMO_RANKING_VALUE = "50"
"""
Sendinblu compte support
"""
SENDINBLUE_API_KEY_SUPPORT = "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"
SENDINBLUE_API_KEY_SUPPORT = "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"
"""
Variable SMTP de OFFICE 365, suite a l'abandon de sendinblu comme relay stmp
"""
O365_SMTP_COUNT_password = 'GomboyaVince1234+'
O365_SMTP_COUNT_smtpsrv = "smtp.office365.com"
O365_SMTP_COUNT_user = "cbalde@mysy-training.com"
O365_SMTP_COUNT_port = 587

File diff suppressed because one or more lines are too long

View File

@ -1,154 +0,0 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--[if gtemso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
<o:PixelsPerInch>96</o:PixelsPerInch>
</o:OfficeDocumentSettings>
</xml><![endif]-->
<title>Sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width">
<style>
html, body {
font-family: 'Arial', sans-serif;
}
</style>
</head>
<body bgcolor="#fff" style="margin:0px; padding:0px; -webkit-text-size-adjust:none;"><!--[if gtemso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
<o:PixelsPerInch>96</o:PixelsPerInch>
</o:OfficeDocumentSettings>
</xml><![endif]-->
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width"><!--[if gtemso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
<o:PixelsPerInch>96</o:PixelsPerInch>
</o:OfficeDocumentSettings>
</xml><![endif]-->
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width">
<table bgcolor="#fff" border="0" cellpadding="0" cellspacing="0" height="100%" style="margin:0 auto;" width="100%">
<tbody>
<tr>
<td align="center" bgcolor="#fafafa" height="100%" width="600">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td bgcolor="white" height="50" style="height:50px;" width="600">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td align="center" height="50" style="height:50px;" valign="middle" width="600"><span style="font-size:12px;"><span style="font-family:Arial,Helvetica,sans-serif;"><a href="#" style="color:#000;">Some inline version</a></span></span></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td bgcolor="#eff2f7" height="69" style="height:69px;" width="600">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td align="center" height="69" style="height:69px;" valign="middle" width="600"><img alt="Mysy Training Logo" src="https://img.mysy-training.com/MYSY-LOGO-BLUE.png" alt="Mysy Training Logo" width="18%" style="display: block;" /></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td bgcolor="#fff" height="165" style="height:165px;" width="600">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td align="center" height="165" style="height:165px;" valign="middle" width="600">
<div style="display: block;">
<div style="margin-left: auto; margin-right: auto">
<div style="text-align: center; font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: small; line-height: 1.4rem;color: #3b3e40;">
<p style="font-size:medium">Activation du votre compte professionnel MySy Training </p>
<p> Bonjour {{ params.user_name }}</p>
<p style="text-align:justify">
<p style="text-align:justify">
Vous avez fait une demande de création d'un compte professionnel sur mysy-training.com.</p>
<p style="text-align:justify">La securité des vos données est primordiale pour nous. Une fois que vous aurez activez votre compte vous allez recevoir <font color="red"> une clé secrète </font> necessaire pour vous connecter.</p>
<p style="text-align:justify">Pour activer votre compte, veuillez cliquer sur le lien ci-dessous. </p>
</p>
<br/>
<a href={{params.mysyurl}}>
<button style="background-color:#619E31; border-radius: 20px;padding-left: 10px;
padding-right: 10px; padding-top: 5px;
padding-bottom: 5px;cursor:pointer;min-width: 5rem; color: white;
width: 10rem;"> Valider </button>
</a>
<p style="text-align:justify">
<p style="text-align:justify; color: red; text-decoration: underline;">Important </p>
<p style="text-align:justify">
Pour vous connecter entant que professionnel sur le
site mysy-training.com, la clé secrete et le mot de passe sont necessaires.</p>
</p>
<p style="font-size:x-small;margin-top: 1rem; line-height: normal;">
Cordialement<br/>
MySy Training Technology<br/>
Contact : +337 69 20 39 45<br/>
Email : contact@mysy-training.com<br/>
</p>
</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td bgcolor="#fff" width="600">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td align="center" valign="middle" width="600">
<div style="
padding: 10px 20px;
margin-bottom: 1rem;
color: #858588;
">
<p style="font-size:xx-small; text-align: center;font-family: Verdana, Geneva, Tahoma, sans-serif;">
Cet email a été envoyé à {{user.email}} <br />
Ce mail vous est adressé par MYSY Training dont le siège social est situé au 1 Cr du Havre, 75008 Paris. Conformément à la Loi Informatique et Liberté Loi n° 78-17 du 6 janvier 1978 modifiée et au Règlement Général sur la Protection des Données Règlement (UE) 2016/679 du Parlement européen et du Conseil du 27 avril 2016 dit RGPD, vous disposez d'un droit d'accès, de rectification, d'effacement, de limitation et d'opposition au traitement de vos données. Vous pouvez exercer vos droits par courrier postal envoyé à : MYSY Training 1 Cr du Havre, 75008 Paris ou par mail : contact@mysy-training.com.
<br/>
<a href="#">Se désinscrire</a><br/>
</p>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</body>
</html>

View File

@ -54,11 +54,11 @@
</td>
</tr>
<tr>
<td bgcolor="#eff2f7" height="69" style="height:69px;" width="600">
<td bgcolor="#104277" height="69" style="height:69px;" width="600">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td align="center" height="69" style="height:69px;" valign="middle" width="600"><img alt="Mysy Training Logo" src="https://img.mysy-training.com/MYSY-LOGO-BLUE.png" alt="Mysy Training Logo" width="18%" style="display: block;" /></td>
<td align="center" height="69" style="height:69px;" valign="middle" width="600"><img alt="Mysy Training Logo" src="https://img.mysy-training.com/MYSY-LOGO-WHITE.png" alt="Mysy Training Logo" width="18%" style="display: block;" /></td>
</tr>
</tbody>
</table>
@ -76,7 +76,7 @@
<div style="text-align: center; font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: small; line-height: 1.4rem;color: #3b3e40;">
<p style="font-size:medium">Confirmation de votre commande n° {{params.order_id}}</p>
<p style="font-size:small; font-weight:bold">Confirmation de votre commande n° {{params.order_id}}</p>
<p style="text-align:right; font-size: small;">
{{params.client_name}}<br/>
{{params.client_address}}<br/>
@ -175,7 +175,7 @@ Date de commande : {{params.date_order}}<br/>
</td>
</tr>
<tr>
<td bgcolor="#fff" width="600">
<td bgcolor="#104277" width="600">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
@ -185,7 +185,7 @@ Date de commande : {{params.date_order}}<br/>
padding: 10px 20px;
margin-bottom: 1rem;
color: #858588;
color: #ffffff;
">
<p style="font-size:xx-small; text-align: center;font-family: Verdana, Geneva, Tahoma, sans-serif;">
Cet email a été envoyé à {{params.client_email}} <br />

View File

@ -14,6 +14,8 @@ from dateutil import tz
import pytz
import sib_api_v3_sdk
from sib_api_v3_sdk.rest import ApiException
import jinja2
from email.message import EmailMessage
configuration = sib_api_v3_sdk.Configuration()
configuration.api_key['api-key'] = MYSY_GV.SENDINBLUE_API_KEY_SUPPORT
@ -57,18 +59,18 @@ def incription_training_confirmation_mail(diction):
tomorrow_day = tomorrow.strftime("%A")
print("debut envoi mail de test ")
# on rentre les renseignements pris sur le site du fournisseur
msg = MIMEMultipart("alternative")
msg['Subject'] = 'MySy Training : Confirmation inscription formation'
msg['From'] = 'contact@mysy-training.com'
msg['To'] = str(diction['email'])
to = [{"email": str(diction['email'])}]
bcc = [{"email": "contact@mysy-training.com"}]
"""
Verification si c'est une formation en ligne.
auquel cas, l'adresse est du type : enligne"""
print(" ### Adresse = "+str(diction['adresse']) )
adresse_session = str(diction['adresse'])
trim_adr = str(diction['adresse']).strip().replace(" ","").lower()
if (trim_adr == "enligne"):
adresse_session = "enligne"
"""
send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(template_id=1, params={ "nom": str(diction['nom']),
"prenom":str(diction['prenom']),
"date_du": str(diction['date_du']),
@ -76,11 +78,52 @@ def incription_training_confirmation_mail(diction):
"adresse": str(diction['adresse']),
"title":str(diction['title'])},
to=to, bcc=bcc )
"""
api_response = api_instance.send_transac_email(send_smtp_email)
print(api_response)
print("debut envoi mail de test ")
# on rentre les renseignements pris sur le site du fournisseur
return True, " Email bien envoyé"
# msg = MIMEMultipart("alternative")
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
msg = EmailMessage()
# JINJA2
templateLoader = jinja2.FileSystemLoader(searchpath="./")
templateEnv = jinja2.Environment(loader=templateLoader)
TEMPLATE_FILE = "Template/MySy_confirmation_inscription_formation_tpl.html"
template = templateEnv.get_template(TEMPLATE_FILE)
# This data can come from database query
body = {
"params" :{"nom": str(diction['nom']),
"prenom": str(diction['prenom']),
"date_du": str(diction['date_du']),
"date_fin": str(diction['date_au']),
"adresse": str(adresse_session),
"title": str(diction['title']),
"email": str(diction['email'])},
}
sourceHtml = template.render(params=body["params"])
msg.set_content(sourceHtml, subtype='html')
msg['From'] = 'cbalde@mysy-training.com'
msg['Cc'] = 'contact@mysy-training.com'
msg['Subject'] = '[MySy Training]: Confirmation inscription formation'
msg['To'] = str(diction['email'])
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
val = smtpserver.send_message(msg)
smtpserver.close()
print(" Email confirlation envoyé " + str(val))
return True, " Email confirlation inscritpion bien envoyé"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
@ -123,16 +166,50 @@ def Pre_incription_training_confirmation_mail(diction):
bcc = [{"email": "contact@mysy-training.com"}]
print(" ### Adresse = "+str(diction['adresse']) )
send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(template_id=2, params={ "nom": str(diction['nom']),
"""send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(template_id=2, params={ "nom": str(diction['nom']),
"prenom":str(diction['prenom']),
"date_du": str(diction['date_du']),
"date_fin": str(diction['date_au']),
"adresse": str(diction['adresse']),
"title":str(diction['title'])},
to=to, bcc=bcc )
"""
# msg = MIMEMultipart("alternative")
msg = EmailMessage()
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
api_response = api_instance.send_transac_email(send_smtp_email)
print(api_response)
# JINJA2
templateLoader = jinja2.FileSystemLoader(searchpath="./")
templateEnv = jinja2.Environment(loader=templateLoader)
TEMPLATE_FILE = "Template/MySy_confirmation_inscription_formation_tpl.html"
template = templateEnv.get_template(TEMPLATE_FILE)
# This data can come from database query
body = {
"params":{"nom": str(diction['nom']),
"prenom": str(diction['prenom']),
"date_du": str(diction['date_du']),
"date_fin": str(diction['date_au']),
"adresse": str(diction['adresse']),
"title": str(diction['title']),
"email": str(diction['email'])},
}
sourceHtml = template.render(params=body["params"])
msg.set_content(sourceHtml, subtype='html')
msg['From'] = 'cbalde@mysy-training.com'
msg['Cc'] = 'contact@mysy-training.com'
msg['Subject'] = '[MySy Training] : pre-inscription formation'
msg['To'] = str(diction['email'])
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
val = smtpserver.send_message(msg)
smtpserver.close()
print(" Email envoyé " + str(val))
return True, " Email bien envoyé"

View File

@ -39,7 +39,7 @@ password = 'yGmzqBfrjb3YCvQN'
def send_user_account_mail(message, account_mail):
def send_user_account_mail_old(message, account_mail):
try:
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
tomorrow_day = tomorrow.strftime("%A")
@ -83,7 +83,7 @@ Cette fonction envoie un mail de remerciement apres l'activation
du compte d'un utilisateur
'''
def send_user_thks_mail(message, account_mail):
def send_user_thks_mail_old(message, account_mail):
try:
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
tomorrow_day = tomorrow.strftime("%A")
@ -105,7 +105,7 @@ def send_user_thks_mail(message, account_mail):
if (MYSY_GV.MYSY_ENV == "PROD"):
my_url = "https://apimysy.iexercice.com/myclass/api/valide_user_account/" + str(message)
elif (MYSY_GV.MYSY_ENV == "DEV"):
my_url = "http://localhost:5000/myclass/api/valide_user_account/" + str(message)
my_url = "http://localhost:"+str(MYSY_GV.MYSY_PORT_DEV)+"/myclass/api/valide_user_account/" + str(message)
@ -123,7 +123,7 @@ def send_user_thks_mail(message, account_mail):
return False, " Impossible d'envoyer l'email de notification "
def send_partner_account_mail(message, account_mail):
def send_partner_account_mail_old(message, account_mail):
try:
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
@ -136,7 +136,7 @@ def send_partner_account_mail(message, account_mail):
if (MYSY_GV.MYSY_ENV == "PROD"):
my_url = "https://apimysy.iexercice.com/myclass/api/valide_partnair_account/" + str(message)
elif (MYSY_GV.MYSY_ENV == "DEV"):
my_url = "http://localhost:5000/myclass/api/valide_partnair_account/"+str(message)
my_url = "http://localhost:"+str(MYSY_GV.MYSY_PORT_DEV)+"/myclass/api/valide_partnair_account/"+str(message)
print(" mail enoye à toaddrs : "+toaddrs)
@ -170,12 +170,10 @@ def send_partner_account_mail(message, account_mail):
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible d'envoyer l'email de notification"
'''
Envoie de l'email de reinitialisation du mot de passe du user
'''
def send_user_init_pwd_mail(token, account_mail, type_account):
def send_user_init_pwd_mail_pwd(token, account_mail, type_account):
try:
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
tomorrow_day = tomorrow.strftime("%A")
@ -327,7 +325,7 @@ def SendGenericEmail(mail_recever=None, mail_object=None, mail_message=None):
Apres l'activation du compte pro,
cet email envoie le token et mot de passe temporaire à l'utilisateur
'''
def Pro_Account_Token_Pass(account_mail, my_token):
def Pro_Account_Token_Pass_old(account_mail, my_token):
try:
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
tomorrow_day = tomorrow.strftime("%A")
@ -662,13 +660,9 @@ def MysyGenericEmail( ):
mail_recever = "billardman01@hotmail.com"
mail_object = " new mysy email"
mail_message = " le message : corps du mail "
password = 'GomboyaVince1234+'
smtpsrv = "smtp.office365.com"
smtpserver = smtplib.SMTP(smtpsrv, 587)
user = "cbalde@mysy-training.com"
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
print("debut envoi mail de test ")
@ -752,7 +746,7 @@ def MysyGenericEmail( ):
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.login(user, password)
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
smtpserver.send_message(msg)
smtpserver.close()
@ -788,11 +782,9 @@ def MysyGenericEmail_tpl():
mail_recever = "billardman01@hotmail.com,cherif.balde@yahoo.fr,cbalde@mysy-training.com"
mail_object = " new mysy email"
mail_message = " le message : corps du mail "
password = 'GomboyaVince1234+'
smtpsrv = "smtp.office365.com"
smtpserver = smtplib.SMTP(smtpsrv, 587)
user = "cbalde@mysy-training.com"
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
print("debut envoi mail de test ")
# on rentre les renseignements pris sur le site du fournisseur
@ -829,7 +821,7 @@ def MysyGenericEmail_tpl():
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.login(user, password)
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
smtpserver.send_message(msg)
smtpserver.close()
@ -866,10 +858,10 @@ def MysyOrderEmail_tpl():
mail_object = " new mysy email"
mail_message = " le message : corps du mail "
password = 'GomboyaVince1234+'
smtpsrv = "smtp.office365.com"
smtpserver = smtplib.SMTP(smtpsrv, 587)
user = "cbalde@mysy-training.com"
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
print("debut envoi mail de test ")
# on rentre les renseignements pris sur le site du fournisseur
@ -918,7 +910,7 @@ def MysyOrderEmail_tpl():
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.login(user, password)
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
smtpserver.send_message(msg)
smtpserver.close()
@ -988,14 +980,7 @@ def SalesOrderConfirmationEmail(account_mail, diction):
mycommon.myprint(str(inspect.stack()[0][3]) + " - nb_line = '" + nb_line + "' : Aucun produit à facturer")
return False, " Impossible d'envoyer l'email de confirmation"
#print("client_name = "+str(client_name))
#print("client_address = " + str(client_address))
#print("client_zip_ville = " + str(client_zip_ville))
#print("client_pays = " + str(client_pays))
#print("order_id = " + str(order_id))
#print("date_order = " + str(date_order))
#print("nb_line = " + str(nb_line))
#print("End Date = " + str(my_end_date))
# Recuperation des produits (max 3 produits)
# produit 1
@ -1035,10 +1020,7 @@ def SalesOrderConfirmationEmail(account_mail, diction):
receiver = [str(account_mail)]
toaddrs = ", ".join(receiver)
#print(" mail enoye à toaddrs : " + toaddrs)
#print("debut envoi mail de test ")
# on rentre les renseignements pris sur le site du fournisseur
# on rentre les renseignements pris sur le site du fournisseur
msg = MIMEMultipart("alternative")
@ -1079,10 +1061,10 @@ def SalesOrderConfirmationEmail(account_mail, diction):
mail_object = " new mysy email"
mail_message = " le message : corps du mail "
password = 'GomboyaVince1234+'
smtpsrv = "smtp.office365.com"
smtpserver = smtplib.SMTP(smtpsrv, 587)
user = "cbalde@mysy-training.com"
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
print("debut envoi mail de test ")
# on rentre les renseignements pris sur le site du fournisseur
@ -1131,24 +1113,346 @@ def SalesOrderConfirmationEmail(account_mail, diction):
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.login(user, password)
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
smtpserver.send_message(msg)
smtpserver.close()
#--------
api_response = api_instance.send_transac_email(send_smtp_email)
print(api_response)
return True
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False
"""
Envoi du nouvel email de creation de compte avec mes propres template
"""
def send_user_account_mail(message, account_mail):
try:
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
tomorrow_day = tomorrow.strftime("%A")
my_url = ""
if (MYSY_GV.MYSY_ENV == "PROD"):
my_url = "https://apimysy.iexercice.com/myclass/api/valide_user_account/"+str(message)
elif (MYSY_GV.MYSY_ENV == "DEV"):
my_url = "http://localhost:"+str(MYSY_GV.MYSY_PORT_DEV)+"/myclass/api/valide_user_account/"+str(message)
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
print("debut envoi mail de test ")
# on rentre les renseignements pris sur le site du fournisseur
# msg = MIMEMultipart("alternative")
msg = EmailMessage()
# JINJA2
templateLoader = jinja2.FileSystemLoader(searchpath="./")
templateEnv = jinja2.Environment(loader=templateLoader)
TEMPLATE_FILE = "Template/MySy_Create_User_account_tpl.html"
template = templateEnv.get_template(TEMPLATE_FILE)
# This data can come from database query
body = {
"params": {"mysyurl": my_url,
"user_name": str(account_mail),
"id": "122CSR_id"},
}
sourceHtml = template.render(params=body["params"])
msg.set_content(sourceHtml, subtype='html')
msg['Subject'] = '[MySy Training] : Activez votre compte '
msg['From'] = 'cbalde@mysy-training.com'
msg['To'] = str(account_mail)
to = [{"email": str(account_mail)}]
bcc = [{"email": "contact@mysy-training.com"}]
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
val = smtpserver.send_message(msg)
smtpserver.close()
print(" Email envoyé "+str(val))
return True
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible d'envoyer l'email de notification "
"""
Creation du compte PRO avec mes template
"""
def send_partner_account_mail(message, account_mail):
try:
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
tomorrow_day = tomorrow.strftime("%A")
receiver = [str(account_mail)]
toaddrs = ", ".join(receiver)
my_url = ""
if (MYSY_GV.MYSY_ENV == "PROD"):
my_url = "https://apimysy.iexercice.com/myclass/api/valide_partnair_account/" + str(message)
elif (MYSY_GV.MYSY_ENV == "DEV"):
my_url = "http://localhost:"+str(MYSY_GV.MYSY_PORT_DEV)+"/myclass/api/valide_partnair_account/"+str(message)
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
print("debut envoi mail de test ")
# on rentre les renseignements pris sur le site du fournisseur
# msg = MIMEMultipart("alternative")
msg = EmailMessage()
# JINJA2
templateLoader = jinja2.FileSystemLoader(searchpath="./")
templateEnv = jinja2.Environment(loader=templateLoader)
TEMPLATE_FILE = "Template/MySy_Create_PRO_account_tpl.html"
template = templateEnv.get_template(TEMPLATE_FILE)
# This data can come from database query
body = {
"params": {"mysyurl": my_url,
"user_name": str(account_mail),
}
}
sourceHtml = template.render(params=body["params"])
msg.set_content(sourceHtml, subtype='html')
msg['Subject'] = '[MySy Training]: activation de votre compte PRO'
msg['From'] = 'cbalde@mysy-training.com'
msg['To'] = str(toaddrs)
msg['Cc'] = 'contact@mysy-training.com'
to = [{"email": str(account_mail)}]
bcc = [{"email": "contact@mysy-training.com"}]
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
val = smtpserver.send_message(msg)
smtpserver.close()
print(" Email envoyé " + str(val))
return True
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible d'envoyer l'email de notification"
'''
Apres l'activation du compte pro,
cet email envoie le token et mot de passe temporaire à l'utilisateur
'''
def Pro_Account_Token_Pass(account_mail, my_token):
try:
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
tomorrow_day = tomorrow.strftime("%A")
receiver = [str(account_mail)]
toaddrs = ", ".join(receiver)
print(" mail enoye à toaddrs : " + toaddrs)
print("debut envoi mail de test ")
# on rentre les renseignements pris sur le site du fournisseur
"""send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(template_id=18, params={"user_name": str(account_mail), "secrete":str(my_token) },
to=to, bcc=bcc)
"""
print("debut envoi mail de test ")
# on rentre les renseignements pris sur le site du fournisseur
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
# msg = MIMEMultipart("alternative")
msg = EmailMessage()
# JINJA2
templateLoader = jinja2.FileSystemLoader(searchpath="./")
templateEnv = jinja2.Environment(loader=templateLoader)
TEMPLATE_FILE = "Template/MySy_account_pro_enabled_tpl.html"
template = templateEnv.get_template(TEMPLATE_FILE)
# This data can come from database query
body = {
"params":{"user_name": str(account_mail),
"secrete": str(my_token)}
}
sourceHtml = template.render(params=body["params"])
msg.set_content(sourceHtml, subtype='html')
msg['Subject'] = '[MySy Training]: votre compte PRO est pret'
cle = my_token
msg['From'] = 'cbalde@mysy-training.com'
msg['To'] = str(toaddrs)
msg['Cc'] = 'contact@mysy-training.com'
to = [{"email": str(account_mail)}]
bcc = [{"email": "contact@mysy-training.com"}]
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
val = smtpserver.send_message(msg)
smtpserver.close()
print(" Email envoyé " + str(val))
return True
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False
"""
Email d'info apres activation du compte utilisateur
"""
def send_user_thks_mail(message, account_mail):
try:
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
tomorrow_day = tomorrow.strftime("%A")
print("debut envoi mail de test ")
# on rentre les renseignements pris sur le site du fournisseur
my_url = ""
if (MYSY_GV.MYSY_ENV == "PROD"):
my_url = "https://apimysy.iexercice.com/myclass/api/valide_user_account/" + str(message)
elif (MYSY_GV.MYSY_ENV == "DEV"):
my_url = "http://localhost:"+str(MYSY_GV.MYSY_PORT_DEV)+"/myclass/api/valide_user_account/" + str(message)
"""
send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(template_id=16, params={ "user_name": str(account_mail),},
to=to, bcc=bcc )
"""
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
# msg = MIMEMultipart("alternative")
msg = EmailMessage()
# JINJA2
templateLoader = jinja2.FileSystemLoader(searchpath="./")
templateEnv = jinja2.Environment(loader=templateLoader)
TEMPLATE_FILE = "Template/MySy_User_account_enabled_tpl.html"
template = templateEnv.get_template(TEMPLATE_FILE)
# This data can come from database query
body = {
"params":{"user_name": str(account_mail), }
}
sourceHtml = template.render(params=body["params"])
msg.set_content(sourceHtml, subtype='html')
msg['From'] = 'cbalde@mysy-training.com'
msg['Cc'] = 'contact@mysy-training.com'
msg['Subject'] = '[MySy Training]: Votre compte est actif '
msg['To'] = str(account_mail)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
val = smtpserver.send_message(msg)
smtpserver.close()
print(" Email envoyé " + str(val))
return True
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible d'envoyer l'email de notification "
"""
Mail de reinitialisation de mot de passe
"""
def send_user_init_pwd_mail(token, account_mail, type_account):
try:
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
tomorrow_day = tomorrow.strftime("%A")
print("debut envoi mail de test ")
# on rentre les renseignements pris sur le site du fournisseur
my_url = ""
if (MYSY_GV.MYSY_ENV == "PROD"):
my_url = "https://www.mysy-training.com/ResetUserPwd/" + str(token)+"/"+str(type_account)
elif (MYSY_GV.MYSY_ENV == "DEV"):
my_url = "http://localhost:3009/ResetUserPwd/" + str(token)+"/"+str(type_account)
to = [{"email": str(account_mail)}]
bcc = [{"email": "contact@mysy-training.com"}]
"""send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(template_id=19, params={"mysyurl": my_url,
"user_name": str(account_mail),
}, to=to, bcc=bcc
)
"""
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
# msg = MIMEMultipart("alternative")
msg = EmailMessage()
# JINJA2
templateLoader = jinja2.FileSystemLoader(searchpath="./")
templateEnv = jinja2.Environment(loader=templateLoader)
TEMPLATE_FILE = "Template/MySy_User_account_enabled_tpl.html"
template = templateEnv.get_template(TEMPLATE_FILE)
# This data can come from database query
body = {
"params":{"mysyurl": my_url,
"user_name": str(account_mail),
},
}
sourceHtml = template.render(params=body["params"])
msg.set_content(sourceHtml, subtype='html')
msg['From'] = 'cbalde@mysy-training.com'
msg['Cc'] = 'contact@mysy-training.com'
msg['Subject'] = '[MySy Training Technology] : Reinitialisez votre mot de passe'
msg['To'] = str(account_mail)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
val = smtpserver.send_message(msg)
smtpserver.close()
print(" Email envoyé " + str(val))
return True
return True
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible d'envoyer l'email de notification "