From 73db7284cf3dd2d0b0fb5a00b532669bad3d7e6e Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Wed, 18 Dec 2019 21:50:17 +0400 Subject: [PATCH] =?UTF-8?q?umail:=20possibilit=C3=A9=20de=20sp=C3=A9cifier?= =?UTF-8?q?=20le=20type=20de=20body?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pyulib/src/uapps/umail.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/pyulib/src/uapps/umail.py b/lib/pyulib/src/uapps/umail.py index 23e9452..d0e75af 100755 --- a/lib/pyulib/src/uapps/umail.py +++ b/lib/pyulib/src/uapps/umail.py @@ -77,6 +77,7 @@ def run_umail(): ('a:', 'attach=', "Attacher un fichier"), ('t:', 'content-type=', "Spécifier le type de contenu du fichier"), ('f:', 'body=', "Spécifier un fichier contenant le corps du message"), + (None, 'html', "Indiquer que le corps du message est du type text/html. Par défaut, il s'agit de text/plain"), (None, 'gencmd', "Générer une commande à évaluer pour envoyer le mail"), ]) options, args = get_args(None, options, longoptions) @@ -87,6 +88,7 @@ def run_umail(): mbccs = [] body = None bodyfile = None + bodymtype = 'plain' afiles = [] amimetypes = [] gencmd = False @@ -110,6 +112,8 @@ def run_umail(): bodyfile = None elif not path.exists(bodyfile): die("%s: fichier introuvable" % bodyfile) + elif option in ('--html',): + bodymtype = 'html' elif option in ('--gencmd',): gencmd = True @@ -133,14 +137,14 @@ def run_umail(): if not afiles: # Sans attachement, faire un message simple - msg = MIMEText('\n'.join(lines), 'plain') + msg = MIMEText('\n'.join(lines), bodymtype) msg.set_charset('utf-8') else: # Il y a des attachement, faire un multipart msg = MIMEMultipart() #msg.set_charset('utf-8') if lines: - body = MIMEText('\n'.join(lines), 'plain') + body = MIMEText('\n'.join(lines), bodymtype) body.set_charset('utf-8') msg.attach(body) i = 0