From edd666071012ace3af3237161dee775572ad7898 Mon Sep 17 00:00:00 2001 From: boyska Date: Tue, 26 Nov 2024 00:30:15 +0100 Subject: [PATCH] add support for sending emails after completion --- carichello.py | 11 +++++++++++ config.json | 3 +++ 2 files changed, 14 insertions(+) diff --git a/carichello.py b/carichello.py index 09a09da..f707d86 100644 --- a/carichello.py +++ b/carichello.py @@ -357,6 +357,17 @@ class Carichello: return self.error_exception(exc) LOG.info("ready: %s", url) self.set_clipboard(url) + mail_to = self.config.get('mail', {}).get('to', None) + if mail_to: + hostname = subprocess.check_output(['hostname', '-f'], encoding='utf8').strip() + try: + subprocess.run( + ['mail', '-s', 'Nuovo file caricato', mail_to], + input=f"{hostname}\n\n{url}", + encoding='utf8', + ) + except subprocess.CalledProcessError: + LOG.error("error sending email") subprocess.run( [ "zenity", diff --git a/config.json b/config.json index e01a81e..ecb0b39 100644 --- a/config.json +++ b/config.json @@ -1,4 +1,7 @@ { + "mail": { + "to": "foobar@example.com" + }, "backends": [ { "type": "archive.org",