示例#1
0
    def consume(self, event: Mapping[str, Any]) -> None:
        rcpt_to = event['rcpt_to']
        if not is_missed_message_address(rcpt_to):
            # Missed message addresses are one-time use, so we don't need
            # to worry about emails to them resulting in message spam.
            recipient_realm = decode_stream_email_address(rcpt_to)[0].realm
            try:
                rate_limit_mirror_by_realm(recipient_realm)
            except RateLimited:
                msg = email.message_from_string(event["message"])
                logger.warning("MirrorWorker: Rejecting an email from: %s "
                               "to realm: %s - rate limited." %
                               (msg['From'], recipient_realm.name))
                return

        mirror_email(email.message_from_string(event["message"]),
                     rcpt_to=rcpt_to)
示例#2
0
    def consume(self, event: Mapping[str, Any]) -> None:
        rcpt_to = event['rcpt_to']
        msg = email.message_from_bytes(
            base64.b64decode(event["msg_base64"]),
            policy=email.policy.default,
        )
        assert isinstance(msg, EmailMessage)  # https://github.com/python/typeshed/issues/2417
        if not is_missed_message_address(rcpt_to):
            # Missed message addresses are one-time use, so we don't need
            # to worry about emails to them resulting in message spam.
            recipient_realm = decode_stream_email_address(rcpt_to)[0].realm
            try:
                rate_limit_mirror_by_realm(recipient_realm)
            except RateLimited:
                logger.warning("MirrorWorker: Rejecting an email from: %s "
                               "to realm: %s - rate limited.",
                               msg['From'], recipient_realm.name)
                return

        mirror_email(msg, rcpt_to=rcpt_to)
示例#3
0
 def consume(self, event):
     # type: (Mapping[str, Any]) -> None
     mirror_email(email.message_from_string(event["message"]),
                  rcpt_to=event["rcpt_to"],
                  pre_checked=True)
示例#4
0
 def consume(self, event):
     mirror_email(email.message_from_string(event["message"].encode("utf-8")),
                  rcpt_to=event["rcpt_to"], pre_checked=True)
示例#5
0
 def consume(self, event):
     # type: (Mapping[str, Any]) -> None
     mirror_email(email.message_from_string(event["message"]),
                  rcpt_to=event["rcpt_to"], pre_checked=True)
示例#6
0
 def consume(self, event):
     mirror_email(email.message_from_string(
         event["message"].encode("utf-8")),
                  rcpt_to=event["rcpt_to"],
                  pre_checked=True)
示例#7
0
 def consume(self, event: Mapping[str, Any]) -> None:
     message = force_str(event["message"])
     mirror_email(email.message_from_string(message),
                  rcpt_to=event["rcpt_to"], pre_checked=True)