- Add notification for error in create account
Serv :
    - create program for send a mail
'
This commit is contained in:
Kum1ta
2024-09-09 17:33:45 +02:00
parent 50e5d7b964
commit 0deb14c1ce
3 changed files with 125 additions and 8 deletions

108
a.py Normal file
View File

@ -0,0 +1,108 @@
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def envoyer_email_icloud(destinataire, sujet, html_message, expediteur, mot_de_passe):
msg = MIMEMultipart()
nom_expediteur = 'PTME'
msg['From'] = f'{nom_expediteur} <ptme@tmoron.fr>'
msg['To'] = destinataire
msg['Subject'] = sujet
msg.attach(MIMEText(html_message, 'html'))
try:
serveur = smtplib.SMTP('smtp.mail.me.com', 587)
serveur.ehlo()
serveur.starttls()
serveur.ehlo()
serveur.login(expediteur, mot_de_passe)
serveur.sendmail(expediteur, destinataire, msg.as_string())
serveur.quit()
print("E-mail envoyé avec succès !")
except Exception as e:
print(f"Erreur lors de l'envoi de l'e-mail : {e}")
expediteur = 'tom.moron@icloud.com'
mot_de_passe = 'mot_de_passe'
destinataire = 'eddydhj@gmail.com'
sujet = 'Création de compte'
message = '''
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: #1e1e1e;
color: #ffffff;
}
.container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #2c2c2c;
border-radius: 8px;
}
h1 {
text-align: center;
font-size: 24px;
margin-bottom: 50px;
background-color: #1e1e1e;
padding: 20px;
border-radius: 8px;
color: #ffffff;
}
p {
color: #cccccc;
font-size: 16px;
}
.button {
display: inline-block;
padding: 10px 20px;
font-size: 16px;
color: #ffffff;
background-color: #0f0f0f;
border-radius: 5px;
text-decoration: none;
margin: 20px;
margin-left: 25%;
margin-right: 25%;
width: 50%;
text-align: center;
}
.footer {
font-size: 12px;
background-color: #1e1e1e;
padding: 10px;
text-align: center;
border-radius: 8px;
margin-top: 20px;
}
</style>
</head>
<body>
<table class="container" role="presentation">
<tr>
<td>
<h1>Bienvenue chez PTME !</h1>
<p>Bonjour [Nom],</p>
<p>Merci d'avoir créé un compte avec PTME ! Nous sommes ravis de vous accueillir parmi nous.</p>
<p>Pour compléter votre inscription, veuillez vérifier votre adresse e-mail en cliquant sur le bouton ci-dessous :</p>
<p><a href="[Lien de vérification]" class="button">Confirmer mon adresse e-mail</a></p>
<p>Si vous n'avez pas demandé cette inscription, vous pouvez ignorer cet e-mail.</p>
<p>Merci,</p>
<p>L'équipe PTME</p>
<div class="footer">
<p>42, 49 Bd Besson Bey, 16000 Angoulême, France</p>
</div>
</td>
</tr>
</table>
</body>
</html>
'''
envoyer_email_icloud(destinataire, sujet, message, expediteur, mot_de_passe)

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/31 22:17:24 by edbernar #+# #+# */
/* Updated: 2024/08/30 15:42:51 by edbernar ### ########.fr */
/* Updated: 2024/09/09 14:47:26 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,6 +17,7 @@ import { typePrivateListMessage } from "/static/javascript/typeResponse/typePriv
import { typeNewPrivateMessage } from "/static/javascript/typeResponse/typeNewPrivateMessage.js";
import { typePrivateListUser } from "/static/javascript/typeResponse/typePrivateListUser.js";
import { typeAllListUser }from "/static/javascript/typeResponse/typeAllListUser.js";
import { createNotification as CN } from "/static/javascript/notification/main.js";
import { typeLogin } from "/static/javascript/typeResponse/typeLogin.js";
const socket = new WebSocket('/ws');
@ -44,10 +45,18 @@ socket.onmessage = (event) => {
}
if (response.code >= 9000 && response.code <= 9999)
{
try {
errorFunction[errorCode.indexOf(response.code)]();
} catch {
console.warn(response);
if (response.code >= 9014 && response.code <= 9024)
{
console.log(response);
CN.new("Error", response.content);
}
else
{
try {
errorFunction[errorCode.indexOf(response.code)]();
} catch {
console.warn(response);
}
}
}
else

View File

@ -6,12 +6,12 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/28 12:05:53 by edbernar #+# #+# */
/* Updated: 2024/09/06 12:02:53 by edbernar ### ########.fr */
/* Updated: 2024/09/09 13:07:00 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
import { MultiGame } from "./class/MultiGame";
import { SoloGame } from "./class/SoloGame";
// MultiGame.create();
SoloGame.create();
MultiGame.create();
// SoloGame.create();