Refonte sauvegarde MariaDB NAS => VPS2
This commit is contained in:
93
scripts/test_mail.py
Normal file
93
scripts/test_mail.py
Normal file
@@ -0,0 +1,93 @@
|
||||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
|
||||
SMTP_SERVER = "mail.mj91.fr" # ou ton serveur SMTP Synology / OVH
|
||||
SMTP_PORT = 587 # 587 avec STARTTLS, ou 465 en SSL
|
||||
SMTP_USER = "services" # adresse expéditrice
|
||||
SMTP_PASSWORD ="84Bf&c$$1Mx953s8!L2"
|
||||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
|
||||
FROM_EMAIL = "services@domo91.fr"
|
||||
TO_EMAIL = "robots@domo91.fr"
|
||||
|
||||
msg = MIMEMultipart()
|
||||
msg["From"] = FROM_EMAIL
|
||||
msg["To"] = TO_EMAIL
|
||||
msg["Subject"] = "Test mail depuis la VM"
|
||||
|
||||
body = """
|
||||
Bonjour,
|
||||
|
||||
Ceci est un test d'envoi de mail depuis la VM en SSH.
|
||||
|
||||
Si tu reçois ce message, l'envoi SMTP fonctionne.
|
||||
|
||||
Michel
|
||||
"""
|
||||
|
||||
msg.attach(MIMEText(body, "plain"))
|
||||
|
||||
try:
|
||||
print("Connexion au serveur SMTP...")
|
||||
server = smtplib.SMTP(SMTP_SERVER, SMTP_PORT, timeout=20)
|
||||
server.set_debuglevel(1)
|
||||
|
||||
print("Démarrage TLS...")
|
||||
server.starttls()
|
||||
|
||||
print("Authentification...")
|
||||
server.login(SMTP_USER, SMTP_PASSWORD)
|
||||
|
||||
print("Envoi du message...")
|
||||
server.sendmail(FROM_EMAIL, TO_EMAIL, msg.as_string())
|
||||
|
||||
server.quit()
|
||||
print("✅ Mail envoyé avec succès")
|
||||
|
||||
except Exception as e:
|
||||
print("❌ Erreur lors de l'envoi :")
|
||||
print(e)
|
||||
|
||||
FROM_EMAIL = "services@domo91.fr"
|
||||
TO_EMAIL = "robots@domo91.fr"
|
||||
|
||||
msg = MIMEMultipart()
|
||||
msg["From"] = FROM_EMAIL
|
||||
msg["To"] = TO_EMAIL
|
||||
msg["Subject"] = "Test mail depuis la VM"
|
||||
|
||||
body = """
|
||||
Bonjour,
|
||||
|
||||
Ceci est un test d'envoi de mail depuis la VM en SSH.
|
||||
|
||||
Si tu reçois ce message, l'envoi SMTP fonctionne.
|
||||
|
||||
Michel
|
||||
"""
|
||||
|
||||
msg.attach(MIMEText(body, "plain"))
|
||||
|
||||
try:
|
||||
print("Connexion au serveur SMTP...")
|
||||
server = smtplib.SMTP(SMTP_SERVER, SMTP_PORT, timeout=20)
|
||||
server.set_debuglevel(1)
|
||||
|
||||
print("Démarrage TLS...")
|
||||
server.starttls()
|
||||
|
||||
print("Authentification...")
|
||||
server.login(SMTP_USER, SMTP_PASSWORD)
|
||||
|
||||
print("Envoi du message...")
|
||||
server.sendmail(FROM_EMAIL, TO_EMAIL, msg.as_string())
|
||||
|
||||
server.quit()
|
||||
print("✅ Mail envoyé avec succès")
|
||||
|
||||
except Exception as e:
|
||||
print("❌ Erreur lors de l'envoi :")
|
||||
print(e)
|
||||
Reference in New Issue
Block a user