當前位置: 首頁>>代碼示例>>Python>>正文


Python email_utils.EmailParser類代碼示例

本文整理匯總了Python中froide.helper.email_utils.EmailParser的典型用法代碼示例。如果您正苦於以下問題:Python EmailParser類的具體用法?Python EmailParser怎麽用?Python EmailParser使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了EmailParser類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _process_mail

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)
開發者ID:Alexander-Minyushkin,項目名稱:froide,代碼行數:7,代碼來源:foi_mail.py

示例2: test_attachment_name_parsing

 def test_attachment_name_parsing(self):
     with open(p("test_mail_07.txt"), 'rb') as f:
         parser = EmailParser()
         content = f.read()
         mail = parser.parse(BytesIO(content))
         self.assertEqual(len(mail['attachments']), 1)
         self.assertEqual(mail['attachments'][0].name, u'Bescheid Fäker.pdf')
開發者ID:konklone,項目名稱:froide,代碼行數:7,代碼來源:test_mail.py

示例3: test_attachment_name_broken_encoding

 def test_attachment_name_broken_encoding(self):
     with open(p("test_mail_06.txt"), 'rb') as f:
         parser = EmailParser()
         content = f.read()
         mail = parser.parse(BytesIO(content))
         self.assertEqual(len(mail['attachments']), 1)
         self.assertEqual(mail['attachments'][0].name, u'Eingangsbestätigung und Hinweis auf Unzustellbarkeit - Username.pdf')
開發者ID:konklone,項目名稱:froide,代碼行數:7,代碼來源:test_mail.py

示例4: test_attachment_name_parsing_header

 def test_attachment_name_parsing_header(self):
     with open(p("test_mail_10.txt"), 'rb') as f:
         parser = EmailParser()
         content = f.read()
         mail = parser.parse(BytesIO(content))
         self.assertEqual(len(mail.attachments), 1)
         self.assertEqual(mail.attachments[0].name, 'Eingangsbestätigung Akteneinsicht.doc')
開發者ID:stefanw,項目名稱:froide,代碼行數:7,代碼來源:test_mail.py

示例5: _process_mail

def _process_mail(mail_string):
    parser = EmailParser()
    email = parser.parse(mail_string)
    received_list = email['to'] + email['cc'] \
            + email['resent_to'] + email['resent_cc']
            # TODO: BCC?
    from foirequest.models import FoiRequest
    mail_filter = lambda x: x[1].endswith("@%s" % settings.FOI_EMAIL_DOMAIN)
    received_list = filter(mail_filter, received_list)

    # make original mail storeable as unicode
    try:
        mail_string = mail_string.decode("utf-8")
    except UnicodeDecodeError:
        mail_string = base64.b64encode(mail_string).decode("utf-8")

    for received in received_list:
        secret_mail = received[1]
        try:
            foi_request = FoiRequest.objects.get_by_secret_mail(secret_mail)
        except FoiRequest.DoesNotExist:
            if secret_mail.endswith('@%s' % settings.FOI_EMAIL_DOMAIN):
                mail_managers(_('Unknown FoI-Mail Recipient'),
                    unknown_foimail_message % {'address': secret_mail})
            continue
        foi_request.add_message_from_email(email, mail_string)
開發者ID:MechanisM,項目名稱:froide,代碼行數:26,代碼來源:foi_mail.py

示例6: test_borked_subject

 def test_borked_subject(self):
     ''' Subject completly borked '''
     with open(p("test_mail_09.txt"), 'rb') as f:
         parser = EmailParser()
         content = f.read()
         mail = parser.parse(BytesIO(content))
         self.assertIn('Unterlagen nach', mail.subject)
         self.assertIn('E-Mail Empfangsbest', mail.subject)
開發者ID:stefanw,項目名稱:froide,代碼行數:8,代碼來源:test_mail.py

示例7: test_attachment_name_parsing_2

 def test_attachment_name_parsing_2(self):
     with open(p("test_mail_11.txt"), 'rb') as f:
         parser = EmailParser()
         content = f.read()
     mail = parser.parse(BytesIO(content))
     self.assertEqual(mail.subject, 'Bescheid zu Ihrer ergänzten IFG-Anfrage Bestellung Infomaterial, Broschüren... [#32154]')
     self.assertEqual(len(mail.attachments), 1)
     self.assertEqual(mail.attachments[0].name, '20180904_Bescheid Broschüren.pdf')
開發者ID:stefanw,項目名稱:froide,代碼行數:8,代碼來源:test_mail.py

示例8: test_attachment_name_broken_encoding

 def test_attachment_name_broken_encoding(self):
     with open(p("test_mail_06.txt"), 'rb') as f:
         parser = EmailParser()
         content = f.read()
     mail = parser.parse(BytesIO(content))
     self.assertEqual(len(mail.attachments), 2)
     self.assertEqual(mail.attachments[0].name, 'usernameEingangsbestätigung und Hinweis auf Unzustellbarkeit - Username.pdf')
     self.assertEqual(mail.attachments[1].name, '15-725_002 II_0367.pdf')
開發者ID:stefanw,項目名稱:froide,代碼行數:8,代碼來源:test_mail.py

示例9: test_recipient_parsing

 def test_recipient_parsing(self):
     with open(p("test_mail_05.txt"), 'rb') as f:
         parser = EmailParser()
         content = f.read()
         mail = parser.parse(BytesIO(content))
     self.assertEqual(len(mail.cc), 2)
     self.assertEqual(len(mail.to), 3)  # contains X-Original-To as well
     self.assertTrue(mail.is_auto_reply)
開發者ID:stefanw,項目名稱:froide,代碼行數:8,代碼來源:test_mail.py

示例10: deferred_fill_sender

def deferred_fill_sender(apps, schema_editor):
    parser = EmailParser()
    DeferredMessage = apps.get_model('foirequest', 'DeferredMessage')
    for deferred in DeferredMessage.objects.all():
        print(deferred.pk)
        email = parser.parse(BytesIO(base64.b64decode(deferred.mail)))
        deferred.sender = email.from_[1]
        deferred.save()
開發者ID:stefanw,項目名稱:froide,代碼行數:8,代碼來源:0031_auto_20181106_1510.py

示例11: test_eml_attachments

 def test_eml_attachments(self):
     with open(p("test_mail_08.txt"), 'rb') as f:
         parser = EmailParser()
         content = f.read()
         mail = parser.parse(BytesIO(content))
         subject = u'WG: Disziplinarverfahren u.a. gegen B\xfcrgermeister/Hauptverwaltungsbeamte/Amtsdirektoren/ehrenamtliche B\xfcrgermeister/Ortsvorsteher/Landr\xe4te im Land Brandenburg in den letzten Jahren [#5617]'
         self.assertEqual(mail['attachments'][0].name,
             '%s.eml' % subject[:45])
開發者ID:konklone,項目名稱:froide,代碼行數:8,代碼來源:test_mail.py

示例12: _process_mail

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)
開發者ID:stefanw,項目名稱:froide,代碼行數:8,代碼來源:foi_mail.py

示例13: test_attachment_name_parsing

 def test_attachment_name_parsing(self):
     with open(p("test_mail_07.txt"), 'rb') as f:
         parser = EmailParser()
         content = f.read()
     mail = parser.parse(BytesIO(content))
     self.assertEqual(mail.subject, 'Anfrage nach dem Informationsfreiheitsgesetz; Gespräch damaliger BM Steinmeier Matthias Müller VW AG; Vg. 069-2018')
     self.assertEqual(len(mail.attachments), 2)
     self.assertEqual(mail.attachments[0].name, 'Bescheid Fäker.pdf')
     self.assertEqual(mail.attachments[1].name, '180328 Schreiben an Antragstellerin; Vg. 069-2018.pdf')
開發者ID:stefanw,項目名稱:froide,代碼行數:9,代碼來源:test_mail.py

示例14: test_html_only_mail

    def test_html_only_mail(self):
        with open(p("test_mail_13.txt"), 'rb') as f:
            parser = EmailParser()
            content = f.read()
        mail = parser.parse(BytesIO(content))

        self.assertTrue(len(mail.body) > 10)
        # Markdown like links are rendered
        self.assertIn('](https://', mail.body)
        self.assertIn('*[email protected]*', mail.body)
開發者ID:stefanw,項目名稱:froide,代碼行數:10,代碼來源:test_mail.py

示例15: test_bounce_parsing_2

    def test_bounce_parsing_2(self):
        parser = EmailParser()
        with open(p("bounce_002.txt"), 'rb') as f:
            email = parser.parse(f)

        bounce_address = make_bounce_address(self.email)
        email.to = [('', bounce_address)]
        bounce_info = email.bounce_info
        self.assertTrue(bounce_info.is_bounce)
        self.assertEqual(bounce_info.bounce_type, 'hard')
        self.assertEqual(bounce_info.status, (5, 1, 1))
開發者ID:stefanw,項目名稱:froide,代碼行數:11,代碼來源:tests.py


注:本文中的froide.helper.email_utils.EmailParser類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。