3 # Written by Thomas Schneider <qsuscs@qsuscs.de>
4 # This script is placed in public domain. If this is not applicable, consider
5 # it licensed under the CC-0:
6 # <https://creativecommons.org/publicdomain/zero/1.0/>
13 lmtp_host = sys.argv[3] if len(sys.argv) > 3 else 'localhost'
14 lmtp = smtplib.LMTP(lmtp_host, int(sys.argv[1]))
17 # See <http://www.qmail.org/man/man8/qmail-command.html> for qmail command
18 # docs and supplied environment variables. We need to replace "1" with an
19 # empty string, as qmail only supports EXT, EXT2, EXT3, EXT4.
20 arg_ext = sys.argv[2] if sys.argv[2] != "1" else ""
23 os.environ['EXT' + arg_ext] + "@" + os.environ['HOST'],
24 sys.stdin.buffer.read()
26 except smtplib.SMTPResponseException as e:
27 if 400 <= e.smtp_code < 500:
29 # otherwise, it's either a 5xx aka permanent error or something else
30 # is already b0rked, thus raise -> exit(100) -> have qmail return a