From 34853ea46fbd8c389cc8e2cc93ce449a3c277762 Mon Sep 17 00:00:00 2001 From: Ansgar Burchardt Date: Thu, 5 Jul 2012 14:18:50 -0600 Subject: [PATCH] utils (send_message): add option to write mail to files Add an option to write outgoing mails to a file in the directory given by Dir::Mail. This is intended for use on development installations where no real mail should be sent. Signed-off-by: Ansgar Burchardt --- daklib/utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/daklib/utils.py b/daklib/utils.py index 0d2f1fc6..3e299abc 100755 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -23,6 +23,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import commands +import datetime import email.Header import os import pwd @@ -608,6 +609,14 @@ def build_package_list(dsc, session = None): def send_mail (message, filename=""): """sendmail wrapper, takes _either_ a message string or a file as arguments""" + maildir = Cnf.get('Dir::Mail') + if maildir: + path = os.path.join(maildir, datetime.datetime.now().isoformat()) + path = find_next_free(path) + fh = open(path, 'w') + print >>fh, message, + fh.close() + # Check whether we're supposed to be sending mail if Cnf.has_key("Dinstall::Options::No-Mail") and Cnf["Dinstall::Options::No-Mail"]: return -- 2.39.5