From 08b8c46a09b8d08c25c3bbdd5b29d0f4aea8f609 Mon Sep 17 00:00:00 2001 From: Colombain Agathe <agathe.colombain@student-cs.fr> Date: Sun, 30 Mar 2025 20:12:41 +0000 Subject: [PATCH] Upload New File --- testenvoiemail.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 testenvoiemail.py diff --git a/testenvoiemail.py b/testenvoiemail.py new file mode 100644 index 0000000..d42cb81 --- /dev/null +++ b/testenvoiemail.py @@ -0,0 +1,28 @@ +import smtplib +from email.mime.text import MIMEText +from email.mime.multipart import MIMEMultipart + + +def send_mail(email, subject, body): + smtp_server = 'smtp.gmail.com' + smtp_port = 587 + smtp_username = 'agatheccl@gmail.com' + smtp_password = 'wpkg amco ipcr gmbj' + message = MIMEMultipart() + message['From'] = smtp_username + message['To'] = email + message['Subject'] = subject + + message.attach(MIMEText(body, 'plain')) + + with smtplib.SMTP(smtp_server, smtp_port) as server: + server.starttls() + server.login(smtp_username, smtp_password) + + server.sendmail(smtp_username, to_email, message.as_string()) + +to_email = 'agathe@colombain.com' +subject = 'Test d\'envoi d\'e-mail' +body = 'Bonjour, ceci est un test d\'envoi d\'e-mail depuis un script Python.' + +send_mail(to_email, subject, body) \ No newline at end of file -- GitLab