diff options
author | David Timber <dxdt@dev.snart.me> | 2022-05-29 13:55:16 +0800 |
---|---|---|
committer | David Timber <dxdt@dev.snart.me> | 2022-05-29 13:55:16 +0800 |
commit | decf814739a83cb30dff49c89de5152178052c02 (patch) | |
tree | f480bed0a7a68c6a5382a799b0fac38cd813eeed | |
parent | 359971dbf81a6c1de2f4e6cfa59e7e6dde4a7731 (diff) |
boot-report: add "int-opts" in "mua-param"
-rw-r--r-- | src/conf/py-sample/sample.jsonc | 4 | ||||
-rw-r--r-- | src/palhm/__init__.py | 8 |
2 files changed, 10 insertions, 2 deletions
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, |