summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/qmail-lmtp30
1 files changed, 30 insertions, 0 deletions
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 <qsuscs@qsuscs.de>
+# This script is placed in public domain. If this is not applicable, consider
+# it licensed under the CC-0:
+# <https://creativecommons.org/publicdomain/zero/1.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)