1
0
Fork 0

Script to customize Let's Encrypt mails

This commit is contained in:
Luca Beltrame 2021-06-27 08:41:53 +02:00
parent cb21ff0932
commit b49d7d4617
Signed by: einar
GPG key ID: 4707F46E9EC72DEC
2 changed files with 417 additions and 0 deletions

View file

@ -0,0 +1,59 @@
#!/usr/bin/python3
# SPDX-FileCopyrightText: 2021 Luca Beltrame <lbeltrame@kde.org>
#
# SPDX-License-Identifier: BSD-3-Clause
from enum import Enum
import fileinput
import drymail # Vendored
SUBJECT = "Certbot status: {0}"
HEADER = {"X-Notification-Type": "letsencrypt"}
class State(Enum):
renewed = 1
no_action = 2
error = 3
unknown = 4
def __str__(self):
return f'{self.name}'
def main():
state = State.unknown
text = list()
for line in fileinput.input():
line = line.strip()
text.append(line)
if "all renewals succeeded" in line:
state = State.renewed
elif "not due for renewal" in line:
state = State.no_action
text = "\n".join(text)
subject = SUBJECT.format(str(state))
message = drymail.Message(
sender=("Certbot renewal bot", "notify@dennogumi.org"),
receivers=["root"],
subject=subject,
headers=HEADER,
text=text
)
client = drymail.SMTPMailer(
host='localhost')
client.send(message)
if __name__ == "__main__":
main()