Commit ddc3820c authored by Daniel Stan's avatar Daniel Stan

chgpass & stats: utilisation du mail_module

parent 7a1c8627
......@@ -23,7 +23,7 @@ import gestion.affich_tools as affich_tools
import lc_ldap.shortcuts
import lc_ldap.attributs
import lc_ldap.objets
import smtplib
import gestion.mail as mail_module
encoding = getattr(sys.stdout, 'encoding', "UTF-8")
current_user = os.getenv("SUDO_USER") or os.getenv("USER") or os.getenv("LOGNAME") or getpass.getuser()
......@@ -158,9 +158,8 @@ Tentative de changement du mot de passe de %s par %s.
""" % (From, To , login.encode(encoding), current_user)
# Envoi mail
conn = smtplib.SMTP('localhost')
conn.sendmail(From, To , mail )
conn.quit()
with mail_module.ServerConnection() as conn:
conn.sendmail(From, To , mail )
sys.exit(1)
# On peut modifier le MDP
......
......@@ -20,7 +20,6 @@ import gestion.affichage as affichage
import lc_ldap.shortcuts
import psycopg2
import psycopg2.extras
import smtplib
import gestion.config.upload as upload_config
import gestion.config as config
from gestion import mail as mail_module
......@@ -200,7 +199,7 @@ if __name__ == "__main__":
'seuil_upload': upload_config.pretty_seuil,
}).as_string()
mail = smtplib.SMTP('localhost')
mail.sendmail(expediteur, destinataire, corps)
with mail_module.ServerConnection() as conn:
conn.sendmail(expediteur, destinataire, corps)
else:
print fetched_upload_srv
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment