import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.base import MIMEBase from email import encoders import locale import datetime locale.setlocale(category=locale.LC_ALL, locale='fr_FR.utf8') smtp_address = 'smtp.ionos.fr' port = 587 sender = 'No.Reply@educetera.org' receiver = 'cbalde@bigben-connected.com' user = 'No.Reply@educetera.org' password = 'Vince1234!' smtp_address = 'smtp-relay.sendinblue.com' port = 587 sender = 'billardman01@hotmail.com' receiver = ["cherif.balde@yahoo.fr","cbalde@bigben-connected.com"] user = 'billardman01@hotmail.com' password = 'cYa1pk56Zx7EzKmg' def send_user_account_mail(message, account_mail): tomorrow = datetime.date.today() + datetime.timedelta(days=1) tomorrow_day = tomorrow.strftime("%A") receiver = ["cherif.balde@yahoo.fr","cbalde@bigben-connected.com",str(account_mail)] toaddrs = ", ".join(receiver) print(" mail enoye à : "+toaddrs) print("debut envoi mail de test ") # on rentre les renseignements pris sur le site du fournisseur msg = MIMEMultipart("alternative") msg['Subject'] = 'MySy : test email activation compte ' msg['From'] = 'billardman01@hotmail.com' msg['To'] = str(toaddrs) html = '''

Bonjour

Pour valider votre compte, merci de cliquer ici

http://89.156.84.196:5000/myclass/api/valide_user_account/{objId} http://127.0.0.1:5000/myclass/api/valide_user_account/{objId}

Cordialement
L'equipe informatique de MySy

'''.format(code=tomorrow_day, objId=message) html_mime = MIMEText(html, 'html') # msg.attach(texte_mime) msg.attach(html_mime) print("html_mime ="+str(html)) # filename = r"C:\Users\cbalde\OneDrive - bigben-connected.com\Bureau\En cours\SalesOutImport\example2.csv" #attachment = open(filename, "rb") # instance of MIMEBase and named as p #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())) with smtplib.SMTP(smtp_address, port) as server: server.starttls() # Secure the connection server.login(user, password) server.sendmail(sender, toaddrs, msg.as_string()) print("mail successfully sent") def send_partner_account_mail(message, account_mail): tomorrow = datetime.date.today() + datetime.timedelta(days=1) tomorrow_day = tomorrow.strftime("%A") receiver = ["cherif.balde@yahoo.fr","cbalde@bigben-connected.com",str(account_mail)] toaddrs = ", ".join(receiver) print(" mail enoye à : "+toaddrs) print("debut envoi mail de test ") # on rentre les renseignements pris sur le site du fournisseur msg = MIMEMultipart("alternative") msg['Subject'] = 'MySy : test email activation compte ' msg['From'] = 'billardman01@hotmail.com' msg['To'] = str(toaddrs) msg['Cc'] = 'cbalde@bigben-connected.com' html = '''

Bonjour

Vous venez de créer un compte partenaire. Pour activier votre compte, merci de cliquer ici

http://89.156.84.196:5000/myclass/api/valide_partnair_account/{objId} ou http://127.0.0.1:5000/myclass/api/valide_partnair_account/{objId}

Cordialement
L'equipe informatique de MySy

'''.format(code=tomorrow_day, objId=message) html_mime = MIMEText(html, 'html') # msg.attach(texte_mime) msg.attach(html_mime) print("html_mime ="+str(html)) with smtplib.SMTP(smtp_address, port) as server: server.starttls() # Secure the connection server.login(user, password) server.sendmail(sender, toaddrs, msg.as_string()) print("mail successfully sent")