05/04/22 - 10h30

master
ChérifBALDE 2022-04-05 10:57:34 +02:00 committed by cherif
parent 47ab74a287
commit 8dafdc7366
2 changed files with 51 additions and 32 deletions

View File

@ -18,7 +18,7 @@ password = 'Vince1234!'
smtp_address = 'smtp-relay.sendinblue.com' smtp_address = 'smtp-relay.sendinblue.com'
port = 587 port = 587
sender = 'billardman01@hotmail.com' sender = 'billardman01@hotmail.com'
receiver = ["cherif.balde@yahoo.fr","cbalde@bigben-connected.com"] receiver = ["cbalde3@mysy-training.com","billardman1@gmail.com"]
user = 'billardman01@hotmail.com' user = 'billardman01@hotmail.com'
@ -30,7 +30,7 @@ def send_user_account_mail(message, account_mail):
tomorrow = datetime.date.today() + datetime.timedelta(days=1) tomorrow = datetime.date.today() + datetime.timedelta(days=1)
tomorrow_day = tomorrow.strftime("%A") tomorrow_day = tomorrow.strftime("%A")
receiver = ["cherif.balde@yahoo.fr","cbalde@bigben-connected.com",str(account_mail)] receiver = ["billardman01@hotmail.com", "cherif.balde@yahoo.fr", "cbalde@mysy-training.com","billardman1@gmail.com",str(account_mail)]
toaddrs = ",".join(receiver) toaddrs = ",".join(receiver)
print(" mail enoye à : "+toaddrs) print(" mail enoye à : "+toaddrs)
@ -43,35 +43,52 @@ def send_user_account_mail(message, account_mail):
msg['Subject'] = 'MySy : test email activation compte ' msg['Subject'] = 'MySy : test email activation compte '
msg['From'] = 'billardman01@hotmail.com' msg['From'] = 'billardman01@hotmail.com'
msg['To'] = str(toaddrs) msg['To'] = "cherif.balde@yahoo.fr,billardman01@hotmail.com"
html = ''' html = '''
<!DOCTYPE html>
<html> <html>
<body> <body>
<p>Bonjour</p> <div style="background-color:#eee;padding:0px;text-align:center;width:100%">
<p>Pour valider votre compte, merci de cliquer ici </b> </p> <h2 style="font-family:Georgia, 'Times New Roman', Times, serif;color#454349;">
<b> <img src="http://88.170.110.220/img/MYSY-LOGO-BLUE.png" alt="Mysy Training Logo" width="110px" height="70px"/> </h2>
<a href="http://89.156.84.196:5000/myclass/api/valide_user_account/{objId}" target="_blank" > </div>
http://89.156.84.196:5000/myclass/api/valide_user_account/{objId} <div style="padding:20px 0px;text-align:center;font-family:Georgia, 'Times New Roman', Times, serif;color#454349;font-size:2rem;">
</b> <div style="width:100%">
<div style="text-align:center;">
Bonjour
<div style="padding:20px 0px;text-align:center;font-family:Georgia, 'Times New Roman', Times, serif;color#454349;font-size:1rem;">
Votre adresse e-mail a bien été enregistrée sur le site <font color="green">MySy-Training</font>. <br>
Pour valider votre compte, veuillez cliquer sur le lien <font color="green">ci-dessous :</font>
<br/>
<br/>
<b> <a href="https://apimysy.iexercice.com/myclass/api/valide_user_account/{objId}" target="_blank" >
CLIQUEZ ICI
</a> </a>
</b>
</font>
<br/>
<b> <b>
<a href="http://127.0.0.1:5000/myclass/api/valide_user_account/{objId}" target="_blank" > <a href="http://127.0.0.1:5000/myclass/api/valide_user_account/{objId}" target="_blank" >
http://127.0.0.1:5000/myclass/api/valide_user_account/{objId} CLIQUEZ ICI ==> LOCALHOST
</b> </b>
</a> </a>
<p>Cordialement<br> <p>Cordialement<br>
L'equipe informatique de MySy L'equipe informatique de MySy
</p> </p>
</p>
</div>
</div>
</body> </body>
</html> </html>
'''.format(code=tomorrow_day, objId=message) '''.format(code=tomorrow_day, objId=message)
@ -82,17 +99,9 @@ def send_user_account_mail(message, account_mail):
print("html_mime ="+str(html)) print("html_mime ="+str(html))
# filename = r"C:\Users\cbalde\OneDrive - bigben-connected.com\Bureau\En cours\SalesOutImport\example2.csv" toaddr = str(account_mail)
#attachment = open(filename, "rb") cc = ['billardman01@hotmail.com']
# instance of MIMEBase and named as p toaddrs = [toaddr] + cc
#p = MIMEBase('application', 'octet-stream')
# To change the payload into encoded form
#p.set_payload((attachment).read())
# encode into base64
#encoders.encode_base64(p)
#p.add_header('Content-Disposition', "attachment; filename= LogisticReport_GDT.csv")
#msg.attach(p)
# msg.attach(MIMEText(open(filename).read())) # msg.attach(MIMEText(open(filename).read()))
@ -122,7 +131,7 @@ def send_partner_account_mail(message, account_mail):
msg['Subject'] = 'MySy : test email activation compte ' msg['Subject'] = 'MySy : test email activation compte '
msg['From'] = 'billardman01@hotmail.com' msg['From'] = 'billardman01@hotmail.com'
msg['To'] = str(toaddrs) msg['To'] = str(toaddrs)
msg['Cc'] = 'cbalde@bigben-connected.com' msg['Cc'] = 'cbalde@mysy-training.com'
html = ''' html = '''
@ -132,8 +141,8 @@ def send_partner_account_mail(message, account_mail):
<p>Vous venez de créer un compte partenaire. <p>Vous venez de créer un compte partenaire.
Pour activier votre compte, merci de cliquer ici </b> </p> Pour activier votre compte, merci de cliquer ici </b> </p>
<b> <b>
<a href="http://89.156.84.196:5000/myclass/api/valide_partnair_account/{objId}" target="_blank" > <a href="https://apimysy.iexercice.com/myclass/api/valide_partnair_account/{objId}" target="_blank" >
http://89.156.84.196:5000/myclass/api/valide_partnair_account/{objId} https://apimysy.iexercice.com/myclass/api/valide_partnair_account/{objId}
</b> </b>
</a> </a>

12
main.py
View File

@ -18,6 +18,9 @@ import Dev_api_functions as dev_function
from flask_cors import CORS, cross_origin from flask_cors import CORS, cross_origin
import time import time
from OpenSSL import SSL from OpenSSL import SSL
from flask import redirect
from flask import Flask, render_template, request, redirect, url_for
DEBUG_LEVEL = logging.DEBUG DEBUG_LEVEL = logging.DEBUG
LOG_FILE_NAME = "./Log/log_file.log" LOG_FILE_NAME = "./Log/log_file.log"
@ -213,7 +216,14 @@ def valide_user_account(value):
print(" ### validation du compte = ",value) print(" ### validation du compte = ",value)
status, retval = eua.valide_user_account(value) status, retval = eua.valide_user_account(value)
return jsonify(status=status, message=retval)
url = ""
if( status ):
url = 'https://dev.mysy-training.com/login'
else:
url = 'https://dev.mysy-training.com/erreur'
return redirect(url)
''' '''