当前位置: 首页>>代码示例>>Python>>正文


Python notification.parse_smtp_message函数代码示例

本文整理汇总了Python中trac.tests.notification.parse_smtp_message函数的典型用法代码示例。如果您正苦于以下问题:Python parse_smtp_message函数的具体用法?Python parse_smtp_message怎么用?Python parse_smtp_message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parse_smtp_message函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_send_mail

    def test_send_mail(self):
        dir = resource_filename(__name__, os.path.join('..', 'htdocs'))
        files = [os.path.join(dir, f) for f in os.listdir(dir)]
        resources = []
        parent = Resource('repository', '')
        for f in files:
            res = Resource('source', f, parent=parent)
            resources.append(res)

        subjects = ('Re: åäö',
                    u'Re: åäö',
                    'Re: ascii',
                    )
        bodies = ('Here you gö (Här får du)',
                  u'Here you gö (Här får du)',
                  'Ascii body',
                  )
        for subject in subjects:
            subject = to_unicode(subject)
            for body in bodies:
                body = to_unicode(body)
                mail = self.sharesys.send_as_email("anonymous",
                                                   (u'Pöntus Enmärk',
                                                    '[email protected]'),
                                                   [(u'Pontus Enmark',
                                                     '[email protected]'),
                                                    (u'Pöntus Enmärk',
                                                     '[email protected]')],
                                                   subject,
                                                   body,
                                                   *resources)
                headers, sent_body = parse_smtp_message(self.server.get_message())
                assert 'utf-8' in sent_body.split('\n')[2]
                assert subject == headers['Subject'], headers
                assert os.path.basename(files[0]) in sent_body
开发者ID:CGI-define-and-primeportal,项目名称:trac-plugin-sourcesharing,代码行数:35,代码来源:test_sourcesharer.py

示例2: _validate_mimebody

 def _validate_mimebody(self, mime, ticket, newtk):
     """Body of a ticket notification message"""
     (mime_decoder, mime_name, mime_charset) = mime
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=newtk)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     self.failIf('MIME-Version' not in headers)
     self.failIf('Content-Type' not in headers)
     self.failIf('Content-Transfer-Encoding' not in headers)
     self.failIf(not re.compile(r"1.\d").match(headers['MIME-Version']))
     type_re = re.compile(r'^text/plain;\scharset="([\w\-\d]+)"$')
     charset = type_re.match(headers['Content-Type'])
     self.failIf(not charset)
     charset = charset.group(1)
     self.assertEqual(charset, mime_charset)
     self.assertEqual(headers['Content-Transfer-Encoding'], mime_name)
     # checks the width of each body line
     for line in body.splitlines():
         self.failIf(len(line) > MAXBODYWIDTH)
     # attempts to decode the body, following the specified MIME endoding 
     # and charset
     try:
         if mime_decoder:
             body = mime_decoder.decodestring(body)
         body = unicode(body, charset)
     except Exception, e:
         raise AssertionError, e
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:28,代码来源:notification.py

示例3: test_date

 def test_date(self):
     """Date format compliance (RFC822) 
        we do not support 'military' format""" 
     date_str = r"^((?P<day>\w{3}),\s*)*(?P<dm>\d{2})\s+" \
                r"(?P<month>\w{3})\s+(?P<year>200\d)\s+" \
                r"(?P<hour>\d{2}):(?P<min>[0-5][0-9])" \
                r"(:(?P<sec>[0-5][0-9]))*\s" \
                r"((?P<tz>\w{2,3})|(?P<offset>[+\-]\d{4}))$"
     date_re = re.compile(date_str)
     # python time module does not detect incorrect time values
     days = ['Mon','Tue','Wed','Thu','Fri','Sat','Sun']
     months = ['Jan','Feb','Mar','Apr','May','Jun', \
               'Jul','Aug','Sep','Oct','Nov','Dec']
     tz = ['UT','GMT','EST','EDT','CST','CDT','MST','MDT''PST','PDT']
     ticket = Ticket(self.env)
     ticket['reporter'] = '"Joe User" <[email protected]>'
     ticket['summary'] = 'This is a summary'
     ticket.insert()
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     self.failIf('Date' not in headers)
     mo = date_re.match(headers['Date'])
     self.failIf(not mo)
     if mo.group('day'):
         self.failIf(mo.group('day') not in days)
     self.failIf(int(mo.group('dm')) not in range(1,32))
     self.failIf(mo.group('month') not in months)
     self.failIf(int(mo.group('hour')) not in range(0,24))
     if mo.group('tz'):
         self.failIf(mo.group('tz') not in tz)
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:32,代码来源:notification.py

示例4: runTest

 def runTest(self):
     """User password resets notifies admin by mail"""
     self._tester.logout()
     self._smtpd.full_reset() # Clean all previous sent emails
     tc.notfind('Logout')
     # Goto Login
     tc.find("Login")
     tc.follow("Login")
     # Do we have the Forgot passwd link
     tc.find('Forgot your password?')
     tc.follow('Forgot your password?')
     
     username = "foo"
     email_addr = "[email protected]%s.tld" % self._testenv.port
     
     reset_form_name = 'acctmgr_passwd_reset'
     tc.formvalue(reset_form_name, 'username', username)
     tc.formvalue(reset_form_name, 'email', email_addr)
     tc.submit()
     
     headers, body = parse_smtp_message(
         self._smtpd.get_message('[email protected]%s.tld' % self._testenv.port))
     self.assertEqual(headers['Subject'],
                      '[%s] Password reset for user: %s' % (
                                         'testenv%s' % self._testenv.port,
                                         username))
     self.assertEqual(headers['X-URL'], self._testenv.url)
开发者ID:AshKash,项目名称:kit-sink,代码行数:27,代码来源:testcases.py

示例5: test_ignore_domains

 def test_ignore_domains(self):
     """Non-SMTP domain exclusion"""
     self.env.config.set("notification", "ignore_domains", "example.com, example.org")
     self.env.known_users = [
         ("[email protected]", "No Email", ""),
         ("[email protected]", "With Email", "[email protected]"),
     ]
     ticket = Ticket(self.env)
     ticket["reporter"] = "[email protected]"
     ticket["owner"] = "[email protected]"
     ticket["summary"] = "This is a summary"
     ticket.insert()
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     # Msg should always have a 'To' field
     self.failIf("To" not in headers)
     tolist = [addr.strip() for addr in headers["To"].split(",")]
     # 'To' list should not contain addresses with non-SMTP domains
     self.failIf("[email protected]" in tolist)
     self.failIf("[email protected]" in tolist)
     # 'To' list should have been resolved to the actual email address
     self.failIf("[email protected]" not in tolist)
     self.failIf(len(tolist) != 1)
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:25,代码来源:notification.py

示例6: _test_short_login

 def _test_short_login(enabled):
     ticket = Ticket(self.env)
     ticket['reporter'] = 'joeuser'
     ticket['summary'] = 'This is a summary'
     ticket.insert()
     # Be sure that at least one email address is valid, so that we 
     # send a notification even if other addresses are not valid
     self.env.config.set('notification', 'smtp_always_cc',
                         '[email protected]')
     if enabled:
         self.env.config.set('notification', 'use_short_addr', 'true')
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     # Msg should not have a 'To' header
     if not enabled:
         self.failIf('To' in headers)
     else:
         tolist = [addr.strip() for addr in headers['To'].split(',')]
     # Msg should have a 'Cc' field
     self.failIf('Cc' not in headers)
     cclist = [addr.strip() for addr in headers['Cc'].split(',')]
     if enabled:
         # Msg should be delivered to the reporter
         self.failIf(ticket['reporter'] not in tolist)
     else:
         # Msg should not be delivered to joeuser
         self.failIf(ticket['reporter'] in cclist)
     # Msg should still be delivered to the always_cc list
     self.failIf(self.env.config.get('notification',
                 'smtp_always_cc') not in cclist)
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:32,代码来源:notification.py

示例7: test_email_map

 def test_email_map(self):
     """Login-to-email mapping"""
     self.env.config.set("notification", "always_notify_owner", "true")
     self.env.config.set("notification", "always_notify_reporter", "true")
     self.env.config.set("notification", "smtp_always_cc", "[email protected]")
     self.env.known_users = [
         ("joeuser", "Joe User", "[email protected]"),
         ("[email protected]", "Jim User", "[email protected]"),
     ]
     ticket = Ticket(self.env)
     ticket["reporter"] = "joeuser"
     ticket["owner"] = "[email protected]"
     ticket["summary"] = "This is a summary"
     ticket.insert()
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     # Msg should always have a 'To' field
     self.failIf("To" not in headers)
     tolist = [addr.strip() for addr in headers["To"].split(",")]
     # 'To' list should have been resolved to the real email address
     self.failIf("[email protected]" not in tolist)
     self.failIf("[email protected]" not in tolist)
     self.failIf("joeuser" in tolist)
     self.failIf("[email protected]" in tolist)
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:26,代码来源:notification.py

示例8: _test_updater

 def _test_updater(disable):
     if disable:
         self.env.config.set('notification','always_notify_updater',
                             'false')
     ticket = Ticket(self.env)
     ticket['reporter'] = '[email protected]'
     ticket['summary'] = u'This is a súmmäry'
     ticket['cc'] = '[email protected]'
     ticket.insert()
     ticket['component'] = 'dummy'
     now = time.time()
     ticket.save_changes('[email protected]', 'This is a change',
                         when=now)
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=False, modtime=now)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     # checks for header existence
     self.failIf(not headers)
     # checks for updater in the 'To' recipient list
     self.failIf('To' not in headers)
     tolist = [addr.strip() for addr in headers['To'].split(',')]
     if disable:
         self.failIf('[email protected]' in tolist)
     else:
         self.failIf('[email protected]' not in tolist)
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:26,代码来源:notification.py

示例9: _test_default_domain

 def _test_default_domain(enabled):
     self.env.config.set("notification", "always_notify_owner", "false")
     self.env.config.set("notification", "always_notify_reporter", "false")
     self.env.config.set("notification", "smtp_always_cc", "")
     ticket = Ticket(self.env)
     ticket["cc"] = "joenodom, [email protected]"
     ticket["summary"] = "This is a summary"
     ticket.insert()
     # Be sure that at least one email address is valid, so that we
     # send a notification even if other addresses are not valid
     self.env.config.set("notification", "smtp_always_cc", "[email protected]")
     if enabled:
         self.env.config.set("notification", "smtp_default_domain", "example.org")
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     # Msg should always have a 'Cc' field
     self.failIf("Cc" not in headers)
     cclist = [addr.strip() for addr in headers["Cc"].split(",")]
     self.failIf("[email protected]" not in cclist)
     self.failIf("[email protected]" not in cclist)
     if not enabled:
         self.failIf(len(cclist) != 2)
         self.failIf("joenodom" in cclist)
     else:
         self.failIf(len(cclist) != 3)
         self.failIf("[email protected]" not in cclist)
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:28,代码来源:notification.py

示例10: _test_short_login

 def _test_short_login(enabled):
     ticket = Ticket(self.env)
     ticket["reporter"] = "joeuser"
     ticket["summary"] = "This is a summary"
     ticket.insert()
     # Be sure that at least one email address is valid, so that we
     # send a notification even if other addresses are not valid
     self.env.config.set("notification", "smtp_always_cc", "[email protected]")
     if enabled:
         self.env.config.set("notification", "use_short_addr", "true")
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     # Msg should not have a 'To' header
     if not enabled:
         self.failIf("To" in headers)
     else:
         tolist = [addr.strip() for addr in headers["To"].split(",")]
     # Msg should have a 'Cc' field
     self.failIf("Cc" not in headers)
     cclist = [addr.strip() for addr in headers["Cc"].split(",")]
     if enabled:
         # Msg should be delivered to the reporter
         self.failIf(ticket["reporter"] not in tolist)
     else:
         # Msg should not be delivered to joeuser
         self.failIf(ticket["reporter"] in cclist)
     # Msg should still be delivered to the always_cc list
     self.failIf(self.env.config.get("notification", "smtp_always_cc") not in cclist)
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:30,代码来源:notification.py

示例11: test_date

 def test_date(self):
     """Date format compliance (RFC822) 
        we do not support 'military' format"""
     date_str = (
         r"^((?P<day>\w{3}),\s*)*(?P<dm>\d{2})\s+"
         r"(?P<month>\w{3})\s+(?P<year>\d{4})\s+"
         r"(?P<hour>\d{2}):(?P<min>[0-5][0-9])"
         r"(:(?P<sec>[0-5][0-9]))*\s"
         r"((?P<tz>\w{2,3})|(?P<offset>[+\-]\d{4}))$"
     )
     date_re = re.compile(date_str)
     # python time module does not detect incorrect time values
     days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
     months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
     tz = ["UT", "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", "PDT"]
     ticket = Ticket(self.env)
     ticket["reporter"] = '"Joe User" <[email protected]>'
     ticket["summary"] = "This is a summary"
     ticket.insert()
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     self.failIf("Date" not in headers)
     mo = date_re.match(headers["Date"])
     self.failIf(not mo)
     if mo.group("day"):
         self.failIf(mo.group("day") not in days)
     self.failIf(int(mo.group("dm")) not in range(1, 32))
     self.failIf(mo.group("month") not in months)
     self.failIf(int(mo.group("hour")) not in range(0, 24))
     if mo.group("tz"):
         self.failIf(mo.group("tz") not in tz)
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:33,代码来源:notification.py

示例12: test_ignore_domains

 def test_ignore_domains(self):
     """Non-SMTP domain exclusion"""
     self.env.config.set('notification', 'ignore_domains',
                         'example.com, example.org')
     self.env.known_users = \
         [('[email protected]', 'No Email', ''), 
          ('[email protected]', 'With Email', '[email protected]')]
     ticket = Ticket(self.env)
     ticket['reporter'] = '[email protected]'
     ticket['owner'] = '[email protected]org'
     ticket['summary'] = 'This is a summary'
     ticket.insert()
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     # Msg should always have a 'To' field
     self.failIf('To' not in headers)
     tolist = [addr.strip() for addr in headers['To'].split(',')]
     # 'To' list should not contain addresses with non-SMTP domains
     self.failIf('[email protected]' in tolist)
     self.failIf('[email protected]' in tolist)
     # 'To' list should have been resolved to the actual email address
     self.failIf('[email protected]' not in tolist)
     self.failIf(len(tolist) != 1)
开发者ID:gdgkyoto,项目名称:kyoto-gtug,代码行数:25,代码来源:notification.py

示例13: _test_default_domain

 def _test_default_domain(enabled):
     self.env.config.set('notification', 'always_notify_owner',
                         'false')
     self.env.config.set('notification', 'always_notify_reporter',
                         'false')
     self.env.config.set('notification', 'smtp_always_cc', '')
     ticket = Ticket(self.env)
     ticket['cc'] = 'joenodom, [email protected]'
     ticket['summary'] = 'This is a summary'
     ticket.insert()
     # Be sure that at least one email address is valid, so that we 
     # send a notification even if other addresses are not valid
     self.env.config.set('notification', 'smtp_always_cc',
                         '[email protected]')
     if enabled:
         self.env.config.set('notification', 'smtp_default_domain',
                             'example.org')
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
     # Msg should always have a 'Cc' field
     self.failIf('Cc' not in headers)
     cclist = [addr.strip() for addr in headers['Cc'].split(',')]
     self.failIf('[email protected]' not in cclist)
     self.failIf('[email protected]' not in cclist)
     if not enabled:
         self.failIf(len(cclist) != 2)
         self.failIf('joenodom' in cclist)
     else:
         self.failIf(len(cclist) != 3)
         self.failIf('[email protected]' not in cclist)
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:32,代码来源:notification.py

示例14: test_md5_digest

 def test_md5_digest(self):
     """MD5 digest w/ non-ASCII recipient address (#3491)"""
     self.env.config.set("notification", "always_notify_owner", "false")
     self.env.config.set("notification", "always_notify_reporter", "true")
     self.env.config.set("notification", "smtp_always_cc", "")
     ticket = Ticket(self.env)
     ticket["reporter"] = u'"Jöe Usèr" <[email protected]>'
     ticket["summary"] = u"This is a summary"
     ticket.insert()
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:13,代码来源:notification.py

示例15: test_md5_digest

 def test_md5_digest(self):
     """MD5 digest w/ non-ASCII recipient address (#3491)"""
     self.env.config.set('notification', 'always_notify_owner', 'false')
     self.env.config.set('notification', 'always_notify_reporter', 'true')
     self.env.config.set('notification', 'smtp_always_cc', '')
     ticket = Ticket(self.env)
     ticket['reporter'] = u'"Jöe Usèr" <[email protected]>'
     ticket['summary'] = u'This is a summary'
     ticket.insert()
     tn = TicketNotifyEmail(self.env)
     tn.notify(ticket, newticket=True)
     message = notifysuite.smtpd.get_message()
     (headers, body) = parse_smtp_message(message)
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:13,代码来源:notification.py


注:本文中的trac.tests.notification.parse_smtp_message函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。