Пример #1
0
def _process_mail(mail_string, mail_type=None):
    parser = EmailParser()
    if mail_type is None:
        email = parser.parse(BytesIO(mail_string))
    elif mail_type == 'postmark':
        email = parser.parse_postmark(json.loads(mail_string.decode('utf-8')))
    return _deliver_mail(email, mail_string=mail_string)
Пример #2
0
def _process_mail(mail_bytes, mail_type=None, manual=False):
    parser = EmailParser()
    if mail_type is None:
        email = parser.parse(BytesIO(mail_bytes))
    elif mail_type == 'postmark':
        email = parser.parse_postmark(json.loads(mail_bytes.decode('utf-8')))
    return _deliver_mail(email, mail_bytes=mail_bytes, manual=manual)
Пример #3
0
def _process_mail(mail_string, mail_type=None, manual=False):
    parser = EmailParser()
    if mail_type is None:
        email = parser.parse(BytesIO(mail_string))
    elif mail_type == 'postmark':
        email = parser.parse_postmark(json.loads(mail_string.decode('utf-8')))
    return _deliver_mail(email, mail_string=mail_string, manual=manual)
Пример #4
0
def _process_mail(mail_bytes, mail_type=None, manual=False):
    parser = EmailParser()
    if mail_type is None:
        with closing(BytesIO(mail_bytes)) as stream:
            email = parser.parse(stream)
    elif mail_type == 'postmark':
        email = parser.parse_postmark(json.loads(mail_bytes.decode('utf-8')))
    return _deliver_mail(email, mail_bytes=mail_bytes, manual=manual)
Пример #5
0
def _process_mail(mail_bytes, mail_uid=None, mail_type=None, manual=False):
    parser = EmailParser()
    email = None
    if mail_type is None:
        with closing(BytesIO(mail_bytes)) as stream:
            email = parser.parse(stream)
    elif mail_type == 'postmark':
        email = parser.parse_postmark(json.loads(mail_bytes.decode('utf-8')))
    assert email is not None

    _deliver_mail(email, mail_bytes=mail_bytes, manual=manual)

    # Unflag mail after delivery is complete
    if mail_uid is not None:
        with get_foi_mail_client() as mailbox:
            unflag_mail(mailbox, mail_uid)
Пример #6
0
 def auto_redeliver(self, request, queryset):
     import json
     parser = EmailParser()
     for deferred in queryset:
         logger.info("Encoded email: {0}".format(deferred.encoded_mail()))
         email = parser.parse_postmark(
             json.loads(deferred.encoded_mail().decode('utf-8')))
         # email = parser.parse(BytesIO(deferred.encoded_mail()))
         logger.info("Attempting to parse deferred email {0}".format(email))
         if 'subject' in email:
             logger.info("Email subject is {0}".format(email['subject']))
         match = SUBJECT_REQUEST_ID.search(email['subject'])
         if match is not None:
             try:
                 req = FoiRequest.objects.get(pk=match.group(1))
                 deferred.redeliver(req)
             except FoiRequest.DoesNotExist:
                 continue