From 91a91411f48009a24ccc8951bda081ab61356cc6 Mon Sep 17 00:00:00 2001 From: Thomas Schneider Date: Tue, 2 Feb 2016 19:17:44 +0100 Subject: Add documentation on interfacing with qmail Signed-off-by: Thomas Schneider --- contrib/qmail-lmtp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 contrib/qmail-lmtp (limited to 'contrib') diff --git a/contrib/qmail-lmtp b/contrib/qmail-lmtp new file mode 100755 index 000000000..c6398f892 --- /dev/null +++ b/contrib/qmail-lmtp @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +# +# Written by Thomas Schneider +# This script is placed in public domain. If this is not applicable, consider +# it licensed under the CC-0: +# + +try: + import smtplib + import sys + import os + + lmtp = smtplib.LMTP("localhost", int(sys.argv[1])) + + try: + lmtp.sendmail( + os.environ['SENDER'], + os.environ['EXT' + sys.argv[2]] + "@" + os.environ['HOST'], + sys.stdin.buffer.read() + ) + except smtplib.SMTPResponseException as e: + if 400 <= e.smtp_code < 500: + exit(111) + # otherwise, it's either a 5xx aka permanent error or something else + # is already b0rked, thus raise -> exit(100) -> have qmail return a + # 5xx error + else: + raise +except: + exit(100) -- cgit v1.2.3-70-g09d2