36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
#!/usr/bin/python
|
|
"""
|
|
Python reimplementation of the here shown bash script:
|
|
https://dukun.de/xox/altermime/postfix-altermime-howto-2.html
|
|
|
|
Use at your own risk, comes without warranty.
|
|
|
|
License: GPLv3
|
|
Author: Georg Schlisio
|
|
"""
|
|
|
|
import subprocess
|
|
import sys
|
|
|
|
# disclaimer file
|
|
DISCLAIMER = "/etc/postfix/disclaimers/generic"
|
|
|
|
# Exit codes from <sysexits.h>
|
|
EX_UNAVAILABLE = 69
|
|
|
|
am = subprocess.run(["/usr/bin/altermime",
|
|
"--input=-",
|
|
f"--disclaimer={DISCLAIMER}",
|
|
"--htmltoo",
|
|
"--force-for-bad-html",
|
|
#"--xheader='blablubb'", # example of how to add arbitrary header
|
|
],
|
|
stdin=sys.stdin,
|
|
capture_output=True)
|
|
|
|
if am.returncode > 0:
|
|
sys.exit(EX_UNAVAILABLE)
|
|
|
|
sendmailprocess = subprocess.Popen(["/usr/bin/sendmail"] + sys.argv[1:], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
sendmailprocess.communicate(input=am.stdout)
|