utils/sendmail: DBG_MAIL
This commit is contained in:
parent
010fe3b10e
commit
ed23ac1a08
1 changed files with 6 additions and 6 deletions
|
@ -1,13 +1,12 @@
|
|||
#!/usr/bin/env python
|
||||
#!/bin/bash /usr/scripts/python.sh
|
||||
# -*- coding: utf-8 -*-
|
||||
# TODO: Déprécié soon
|
||||
|
||||
"""API pour envoyer facilement un mail en python
|
||||
Author: Vincent Le Gallic <legallic@crans.org>
|
||||
|
||||
"""
|
||||
|
||||
#: Librairie de communication SMTP
|
||||
import smtplib
|
||||
#: Pour fabriquer un mail en MIME
|
||||
from email.mime.text import MIMEText
|
||||
#: Pour encoder le mail en utf-8
|
||||
|
@ -15,6 +14,8 @@ from email import Charset
|
|||
from email.Utils import formatdate
|
||||
Charset.add_charset('utf-8', Charset.QP, Charset.QP, 'utf-8')
|
||||
|
||||
import gestion.mail as mail_module
|
||||
|
||||
def create_mail(emetteur, destinataires, objet, message, cc=[], more_headers={}):
|
||||
"""Fabrique un mail"""
|
||||
if not isinstance(destinataires, list):
|
||||
|
@ -38,9 +39,8 @@ def actually_sendmail(emetteur, destinataires, mail, debug=False):
|
|||
else:
|
||||
# TODO méthode lazy de connexion au smtp + recyclage d'une ancienne
|
||||
# connexion ??
|
||||
s = smtplib.SMTP('smtp.adm.crans.org')
|
||||
with mail_module.ServerConnection() as s:
|
||||
s.sendmail(emetteur, destinataires, mail.as_string())
|
||||
s.quit()
|
||||
|
||||
def sendmail(emetteur, destinataires, objet, message, cc=[], more_headers={}, debug=False):
|
||||
"""Fabrique le mail et l'envoie"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue