From decf814739a83cb30dff49c89de5152178052c02 Mon Sep 17 00:00:00 2001 From: David Timber Date: Sun, 29 May 2022 13:55:16 +0800 Subject: boot-report: add "int-opts" in "mua-param" --- src/conf/py-sample/sample.jsonc | 4 +++- src/palhm/__init__.py | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/conf/py-sample/sample.jsonc b/src/conf/py-sample/sample.jsonc index 0004a28..b519fdf 100644 --- a/src/conf/py-sample/sample.jsonc +++ b/src/conf/py-sample/sample.jsonc @@ -7,7 +7,9 @@ // "mua": "stdout", "mua": "mailx", // "mua": "aws-sns", - // "mua-param": {}, + "mua-param": { + "int-opts": [ "smtp=localhost" ] + }, "mail-to": [ "root" ] // "subject": "Custom Boot Report Subject from {hostname}", // "header": "Custom header content with {hostname} substitution." diff --git a/src/palhm/__init__.py b/src/palhm/__init__.py index 79a6d3f..90de4fc 100644 --- a/src/palhm/__init__.py +++ b/src/palhm/__init__.py @@ -584,6 +584,7 @@ class MUA (ABC): class MailxMUA (MUA): def __init__ (self, jobj: dict): self.exec = jobj.get("exec", "/bin/mailx") + self.int_opts = jobj.get("int-opts", []) def __str__ (self) -> str: return '''mailx: @@ -595,7 +596,12 @@ class MailxMUA (MUA): recipients: Iterable[str], subject: str, composer: Iterable[str]) -> int: - argv = [ self.exec, "-s", subject ] + recipients + argv = [ self.exec ] + for i in self.int_opts: + argv.append("-S") + argv.append(i) + argv += [ "-s", subject ] + argv += recipients with subprocess.Popen( argv, -- cgit v1.2.3-70-g09d2