Browse Source

do not forward to unverified mailbox

Son NK 4 năm trước cách đây
mục cha
commit
e6dd2f1717
1 tập tin đã thay đổi với 23 bổ sung8 xóa
  1. 23 8
      email_handler.py

+ 23 - 8
email_handler.py

@@ -482,19 +482,34 @@ async def handle_forward(
     # no need to create a copy of message
     if len(mailboxes) == 1:
         mailbox = mailboxes[0]
-        ret.append(
-            await forward_email_to_mailbox(
-                alias, msg, email_log, contact, envelope, smtp, mailbox, user
+        if not mailbox.verified:
+            LOG.debug("Mailbox %s unverified, do not forward", mailbox)
+            return [(False, "550 SL E18 unverified mailbox")]
+        else:
+            ret.append(
+                await forward_email_to_mailbox(
+                    alias, msg, email_log, contact, envelope, smtp, mailbox, user
+                )
             )
-        )
     # create a copy of message for each forward
     else:
         for mailbox in mailboxes:
-            ret.append(
-                await forward_email_to_mailbox(
-                    alias, copy(msg), email_log, contact, envelope, smtp, mailbox, user
+            if not mailbox.verified:
+                LOG.debug("Mailbox %s unverified, do not forward", mailbox)
+                ret.append((False, "550 SL E19 unverified mailbox"))
+            else:
+                ret.append(
+                    await forward_email_to_mailbox(
+                        alias,
+                        copy(msg),
+                        email_log,
+                        contact,
+                        envelope,
+                        smtp,
+                        mailbox,
+                        user,
+                    )
                 )
-            )
 
     return ret