import smtplib from email.message import EmailMessage import time # Configuration SMTP_SERVER = "smtp.example.com" SMTP_PORT = 587 SMTP_USER = "user@example.com" SMTP_PASS = "yourpassword" TO_EMAIL = "destination@example.com" FROM_EMAIL = SMTP_USER # Création du message msg = EmailMessage() msg['Subject'] = "[TEST] SMTP Delay Tracker" msg['From'] = FROM_EMAIL msg['To'] = TO_EMAIL send_timestamp = time.strftime('%Y-%m-%d %H:%M:%S') msg['X-Send-Timestamp'] = send_timestamp msg.set_content(f"Ceci est un test d'envoi SMTP horodaté. Envoyé le {send_timestamp}.") # Envoi try: with smtplib.SMTP(SMTP_SERVER, SMTP_PORT) as server: server.starttls() server.login(SMTP_USER, SMTP_PASS) server.send_message(msg) print(f"Email envoyé avec horodatage {send_timestamp}") except Exception as e: print(f"Erreur d'envoi : {e}")