From 2eabfa372cd9cd346cbeefdc67c01291162b2bb6 Mon Sep 17 00:00:00 2001
From: Pierre Pronchery <pierre@defora.net>
Date: Mon, 31 May 2021 17:02:22 +0200
Subject: [PATCH] connection.py: do not send messages when mail.suppress is set

---
 flask_sendmail/connection.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/flask_sendmail/connection.py b/flask_sendmail/connection.py
index b7d65bc..979d083 100644
--- a/flask_sendmail/connection.py
+++ b/flask_sendmail/connection.py
@@ -18,6 +18,9 @@ def __enter__(self):
         pass
 
     def send(self, message):
+        if self.suppress:
+            return 0
+
         sm = Popen([self.mail.mailer, self.mail.mailer_flags], stdin=PIPE,
                    stdout=PIPE, stderr=STDOUT)
         sm.stdin.write(message.dump())