summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--utils.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/utils.py b/utils.py
index e5eafa4..a33b13b 100644
--- a/utils.py
+++ b/utils.py
@@ -21,11 +21,16 @@ def encrypt(msg: EmailMessage, recipients: list[str]) -> tuple[EmailMessage, boo
if len(rcpt_keys) < 1:
return msg, False
- try:
- enc_msg = pgpy.PGPMessage.new(payload.as_string())
- for key in rcpt_keys:
+ encrypted = False
+ enc_msg = pgpy.PGPMessage.new(payload.as_string())
+ for key in rcpt_keys:
+ try:
enc_msg = key.encrypt(enc_msg)
- except:
+ encrypted = True
+ except:
+ continue
+
+ if not encrypted:
return msg, False
container = MIMEMultipart(