Beispiel #1
0
 def bounce(self):
     """
     Deprecated: use bounce.detect(message).
     """
     if not self._bounce:
         self._bounce = bounce.detect(self)
     return self._bounce
Beispiel #2
0
 def bounce(self):
     """
     Deprecated: use bounce.detect(message).
     """
     if not self._bounce:
         self._bounce = bounce.detect(self)
     return self._bounce
Beispiel #3
0
def test_bounce_detect():
    for i, tc in enumerate([{
        'desc': 'Common bounce example',
        'mime': create.from_string(BOUNCE),
        'result': bounce.Result(
            score=1.875,
            status=u'5.1.1',
            notification=(
                    u"This is the mail system at host mail.example.com.\n\n"
                    u"I'm sorry to have to inform you that your message could not\n"
                    u"be delivered to one or more recipients. It's attached below.\n\n"
                    u"For further assistance, please send mail to postmaster.\n\n"
                    u"If you do so, please include this problem report. You can\n"
                    u"delete your own text from the attached returned message.\n\n"
                    u"                   The mail system\n\n"
                    u"<*****@*****.**>: host\n"
                    u"    gmail-smtp-in.l.google.com[209.85.210.17] said: 550-5.1.1 The email account\n"
                    u"    that you tried to reach does not exist. Please try 550-5.1.1\n"
                    u"    double-checking the recipient's email address for typos or 550-5.1.1\n"
                    u"    unnecessary spaces. Learn more at                              550 5.1.1\n"
                    u"    http://mail.google.com/support/bin/answer.py?answer=6596 17si20661415yxe.22\n"
                    u"    (in reply to RCPT TO command)\n"),
            diagnostic_code=(
                    u"smtp; 550-5.1.1 The email account that you tried to reach does"
                    u"    not exist. Please try 550-5.1.1 double-checking the recipient's email"
                    u"    address for typos or 550-5.1.1 unnecessary spaces. Learn more at"
                    u"    550 5.1.1 http://mail.google.com/support/bin/answer.py?answer=6596"
                    u"    17si20661415yxe.22")),
        'is_bounce': True
    }, {
        'desc': 'Office365 bounce messages lack Content-Description',
        'mime': create.from_string(BOUNCE_OFFICE365),
        'result': bounce.Result(
            score=1.25,
            status=u'5.1.10',
            notification=u'',
            diagnostic_code=(
                    u'smtp;550 5.1.10 RESOLVER.ADR.RecipientNotFound; '
                    u'Recipient [email protected] not found by SMTP address lookup')),
        'is_bounce': True
    }, {
        'desc': 'Regular message',
        'mime': create.from_string(SIGNED),
        'result': bounce.Result(
            score=0.0,
            status=u'',
            notification=u'',
            diagnostic_code=u''),
        'is_bounce': False
    }]):
        print('Test case #%d: %s' % (i, tc['desc']))

        # When
        result = bounce.detect(tc['mime'])

        # Then
        eq_(result, tc['result'])
        eq_(result.is_bounce(), tc['is_bounce'])
Beispiel #4
0
    def bounce(self):
        """ If the message is bounce, retuns bounce object that
        provides the values:

        score - between 0 and 1
        status -  delivery status
        notification - human readable description
        diagnostic_code - smtp diagnostic codes

        Can raise MimeError in case if MIME is screwed
        """
        if not self._bounce:
            self._bounce = bounce.detect(self)
        return self._bounce
Beispiel #5
0
    def bounce(self):
        """ If the message is bounce, retuns bounce object that
        provides the values:

        score - between 0 and 1
        status -  delivery status
        notification - human readable description
        diagnostic_code - smtp diagnostic codes

        Can raise MimeError in case if MIME is screwed
        """
        if not self._bounce:
            self._bounce = bounce.detect(self)
        return self._bounce
Beispiel #6
0
    def bounce(self):
        """
        If the message is NOT bounce, then `None` is returned. Otherwise
        it returns a bounce object that provides the values:
          * score - a value between 0 and 1, where 0 means that the message is
                    definitely not a bounce, and 1 means that is definitely a
                    bounce;
          * status -  delivery status;
          * notification - human readable description;
          * diagnostic_code - smtp diagnostic codes;

        Can raise MimeError in case if MIME is screwed.
        """
        if not self._bounce:
            self._bounce = bounce.detect(self)
        return self._bounce
Beispiel #7
0
    def bounce(self):
        """
        If the message is NOT bounce, then `None` is returned. Otherwise
        it returns a bounce object that provides the values:
          * score - a value between 0 and 1, where 0 means that the message is
                    definitely not a bounce, and 1 means that is definitely a
                    bounce;
          * status -  delivery status;
          * notification - human readable description;
          * diagnostic_code - smtp diagnostic codes;

        Can raise MimeError in case if MIME is screwed.
        """
        if not self._bounce:
            self._bounce = bounce.detect(self)
        return self._bounce
Beispiel #8
0
def test_bounce_detect():
    for i, tc in enumerate([{
            'desc':
            'Common bounce example',
            'mime':
            create.from_string(BOUNCE),
            'result':
            bounce.Result(
                score=1.875,
                status=u'5.1.1',
                notification=
                (u"This is the mail system at host mail.example.com.\n\n"
                 u"I'm sorry to have to inform you that your message could not\n"
                 u"be delivered to one or more recipients. It's attached below.\n\n"
                 u"For further assistance, please send mail to postmaster.\n\n"
                 u"If you do so, please include this problem report. You can\n"
                 u"delete your own text from the attached returned message.\n\n"
                 u"                   The mail system\n\n"
                 u"<*****@*****.**>: host\n"
                 u"    gmail-smtp-in.l.google.com[209.85.210.17] said: 550-5.1.1 The email account\n"
                 u"    that you tried to reach does not exist. Please try 550-5.1.1\n"
                 u"    double-checking the recipient's email address for typos or 550-5.1.1\n"
                 u"    unnecessary spaces. Learn more at                              550 5.1.1\n"
                 u"    http://mail.google.com/support/bin/answer.py?answer=6596 17si20661415yxe.22\n"
                 u"    (in reply to RCPT TO command)\n"),
                diagnostic_code=
                (u"smtp; 550-5.1.1 The email account that you tried to reach does"
                 u"    not exist. Please try 550-5.1.1 double-checking the recipient's email"
                 u"    address for typos or 550-5.1.1 unnecessary spaces. Learn more at"
                 u"    550 5.1.1 http://mail.google.com/support/bin/answer.py?answer=6596"
                 u"    17si20661415yxe.22")),
            'is_bounce':
            True
    }, {
            'desc':
            'Office365 bounce messages lack Content-Description',
            'mime':
            create.from_string(BOUNCE_OFFICE365),
            'result':
            bounce.Result(
                score=1.25,
                status=u'5.1.10',
                notification=u'',
                diagnostic_code=
                (u'smtp;550 5.1.10 RESOLVER.ADR.RecipientNotFound; '
                 u'Recipient [email protected] not found by SMTP address lookup'
                 )),
            'is_bounce':
            True
    }, {
            'desc':
            'Regular message',
            'mime':
            create.from_string(SIGNED),
            'result':
            bounce.Result(score=0.0,
                          status=u'',
                          notification=u'',
                          diagnostic_code=u''),
            'is_bounce':
            False
    }]):
        print('Test case #%d: %s' % (i, tc['desc']))

        # When
        result = bounce.detect(tc['mime'])

        # Then
        eq_(result, tc['result'])
        eq_(result.is_bounce(), tc['is_bounce'])