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


Python utils.make_msgid方法代码示例

本文整理汇总了Python中email.utils.make_msgid方法的典型用法代码示例。如果您正苦于以下问题:Python utils.make_msgid方法的具体用法?Python utils.make_msgid怎么用?Python utils.make_msgid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在email.utils的用法示例。


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

示例1: __init__

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import make_msgid [as 别名]
def __init__(self, environment, refname, short_refname, old, new, rev):
        Change.__init__(self, environment)
        self.change_type = {
            (False, True): "create",
            (True, True): "update",
            (True, False): "delete",
        }[bool(old), bool(new)]
        self.refname = refname
        self.short_refname = short_refname
        self.old = old
        self.new = new
        self.rev = rev
        self.msgid = make_msgid()
        self.diffopts = environment.diffopts
        self.graphopts = environment.graphopts
        self.logopts = environment.logopts
        self.commitlogopts = environment.commitlogopts
        self.showgraph = environment.refchange_showgraph
        self.showlog = environment.refchange_showlog

        self.header_template = REFCHANGE_HEADER_TEMPLATE
        self.intro_template = REFCHANGE_INTRO_TEMPLATE
        self.footer_template = FOOTER_TEMPLATE 
开发者ID:Pagure,项目名称:pagure,代码行数:25,代码来源:git_multimail_upstream.py

示例2: send_email

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import make_msgid [as 别名]
def send_email(msg_to, msg_subject, msg_body, msg_from=None,
        smtp_server='localhost', envelope_from=None,
        headers={}):

  if not msg_from:
    msg_from = app.config['EMAIL_FROM']

  if not envelope_from:
    envelope_from = parseaddr(msg_from)[1]

  msg = MIMEText(msg_body)

  msg['Subject'] = Header(msg_subject)
  msg['From'] = msg_from
  msg['To'] = msg_to
  msg['Date'] = formatdate()
  msg['Message-ID'] = make_msgid()
  msg['Errors-To'] = envelope_from

  if request:
    msg['X-Submission-IP'] = request.remote_addr

  s = smtplib.SMTP(smtp_server)
  s.sendmail(envelope_from, msg_to, msg.as_string())
  s.close() 
开发者ID:hadleyrich,项目名称:GerbLook,代码行数:27,代码来源:utils.py

示例3: testNoEncryptMessageNoMdn

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import make_msgid [as 别名]
def testNoEncryptMessageNoMdn(self):
        """ Test Permutation 1: Sender sends un-encrypted data and does NOT request a receipt. """

        # Create the partner with appropriate settings for this case
        partner = models.Partner.objects.create(name='Client Partner',
                                                as2_name='as2server',
                                                target_url='http://localhost:8080/pyas2/as2receive',
                                                compress=False,
                                                mdn=False)

        # Build and send the message to server
        message_id = emailutils.make_msgid().strip('<>')
        in_message, response = self.buildSendMessage(message_id, partner)

        # Check if a 200 response was received
        self.assertEqual(response.status_code, 200)

        # Check if message was processed successfully
        out_message = models.Message.objects.get(message_id=message_id)
        self.assertEqual(out_message.status, 'S')

        # Check if input and output files are the same
        self.assertTrue(AS2SendReceiveTest.compareFiles(self.payload.file, out_message.payload.file)) 
开发者ID:abhishek-ram,项目名称:pyas2,代码行数:25,代码来源:tests.py

示例4: send_mail_main

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import make_msgid [as 别名]
def send_mail_main(subject, body, config=None):
    if config is None:
        config = current_app.config

    mail_to = config['ADMIN_EMAIL']
    mail_from = config['MAIL_FROM']
    msg = MIMEText(body, 'plain', 'UTF-8')

    msg['Subject'] = subject
    msg['To'] = mail_to
    msg['From'] = mail_from
    msg['Date'] = formatdate()
    msg['Message-ID'] = make_msgid()

    s = smtplib.SMTP(config['SMTP_HOST'])
    s.sendmail(mail_from, [mail_to], msg.as_string())
    s.quit() 
开发者ID:EdwardBetts,项目名称:osm-wikidata,代码行数:19,代码来源:mail.py

示例5: _finish_with_main_wrapper

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import make_msgid [as 别名]
def _finish_with_main_wrapper(content: str, introduction: str) -> (str,
                                                                   {str: str}):
    """
    All emails use the main wrapper. This contains the normal html structure
    @return: A sendable mail object, with the content and the attachments
    """
    # cids link the attached media-files to be displayed inline
    header_cid = make_msgid()
    extender_cid = make_msgid()

    full_content = main_wrapper.substitute(
        content=content, introduction_text=introduction,
        header_cid=header_cid[1:-1], extender_cid=extender_cid[1:-1]
    )

    cids_and_filenames = {}
    cids_and_filenames.update({header_cid: 'header.png'})
    cids_and_filenames.update({extender_cid: 'header_extender.png'})

    return (full_content, cids_and_filenames) 
开发者ID:C0D3D3V,项目名称:Moodle-Downloader-2,代码行数:22,代码来源:mail_formater.py

示例6: test_make_msgid_collisions

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import make_msgid [as 别名]
def test_make_msgid_collisions(self):
        # Test make_msgid uniqueness, even with multiple threads
        class MsgidsThread(Thread):
            def run(self):
                # generate msgids for 3 seconds
                self.msgids = []
                append = self.msgids.append
                make_msgid = utils.make_msgid
                try:
                    clock = time.monotonic
                except AttributeError:
                    clock = time.time
                tfin = clock() + 3.0
                while clock() < tfin:
                    append(make_msgid(domain='testdomain-string'))

        threads = [MsgidsThread() for i in range(5)]
        with start_threads(threads):
            pass
        all_ids = sum([t.msgids for t in threads], [])
        self.assertEqual(len(set(all_ids)), len(all_ids)) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:23,代码来源:test_email.py

示例7: generate

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import make_msgid [as 别名]
def generate(cls, domain=None):
        message_id = make_msgid().strip("<>")
        if domain:
            local = message_id.split('@')[0]
            message_id = "{0}@{1}".format(local, domain)
        return cls(message_id) 
开发者ID:duo-labs,项目名称:isthislegit,代码行数:8,代码来源:wrappers.py

示例8: map_message

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import make_msgid [as 别名]
def map_message(message, table):

    def container(message_id):
        return table.setdefault(message_id, Container())

    w = Wrapper(message)
    this = container(w.message_id)

    # process case when we have two messages
    # with the same id, we should put
    # our current message to another container
    # otherwise the message would be lost
    if this.message:
        fake_id = make_msgid()
        this = container(fake_id)
    this.message = w

    # link message parents together
    prev = None
    for parent_id in w.references:
        parent = container(parent_id)
        if prev and not parent.parent and not introduces_loop(prev, parent):
            prev.add_child(parent)
        prev = parent

    # process case where this message has parent
    # unlink the old parent in this case
    if this.parent:
        this.parent.remove_child(this)

    # link to the cool parent instead
    if prev and not introduces_loop(prev, this):
        prev.add_child(this) 
开发者ID:duo-labs,项目名称:isthislegit,代码行数:35,代码来源:threading.py

示例9: __init__

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import make_msgid [as 别名]
def __init__(self, message):
        self.message = message
        self.message_id = message.message_id or make_msgid()
        self.references = message.references
        #self.subject = message.subject
        #self.clean_subject = message.clean_subject 
开发者ID:duo-labs,项目名称:isthislegit,代码行数:8,代码来源:threading.py

示例10: testNoEncryptMessageMdn

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import make_msgid [as 别名]
def testNoEncryptMessageMdn(self):
        """ Test Permutation 2: Sender sends un-encrypted data and requests an unsigned receipt. """

        # Create the partner with appropriate settings for this case
        partner = models.Partner.objects.create(name='Client Partner',
                                                as2_name='as2server',
                                                target_url='http://localhost:8080/pyas2/as2receive',
                                                compress=False,
                                                mdn=True)

        # Setup the message object and buid the message
        message_id = emailutils.make_msgid().strip('<>')
        in_message, response = self.buildSendMessage(message_id, partner)

        # Check if a 200 response was received
        self.assertEqual(response.status_code, 200)

        # Check if message was processed successfully
        out_message = models.Message.objects.get(message_id=message_id)
        self.assertEqual(out_message.status, 'S')

        # Process the MDN for the in message and check status
        AS2SendReceiveTest.buildMdn(in_message, response)
        self.assertEqual(in_message.status, 'S')

        # Check if input and output files are the same
        self.assertTrue(AS2SendReceiveTest.compareFiles(self.payload.file, out_message.payload.file)) 
开发者ID:abhishek-ram,项目名称:pyas2,代码行数:29,代码来源:tests.py

示例11: testNoEncryptMessageSignMdn

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import make_msgid [as 别名]
def testNoEncryptMessageSignMdn(self):
        """ Test Permutation 3: Sender sends un-encrypted data and requests an signed receipt. """

        # Create the partner with appropriate settings for this case
        partner = models.Partner.objects.create(name='Client Partner',
                                                as2_name='as2server',
                                                target_url='http://localhost:8080/pyas2/as2receive',
                                                compress=False,
                                                mdn=True,
                                                mdn_mode='SYNC',
                                                mdn_sign='sha1',
                                                signature_key=self.server_crt)

        # Setup the message object and buid the message
        message_id = emailutils.make_msgid().strip('<>')
        in_message, response = self.buildSendMessage(message_id, partner)

        # Check if a 200 response was received
        self.assertEqual(response.status_code, 200)

        # Check if message was processed successfully
        out_message = models.Message.objects.get(message_id=message_id)
        # AS2SendReceiveTest.printLogs(out_message)
        self.assertEqual(out_message.status, 'S')

        # Process the MDN for the in message and check status
        AS2SendReceiveTest.buildMdn(in_message, response)
        # AS2SendReceiveTest.printLogs(in_message)
        self.assertEqual(in_message.status, 'S')

        # Check if input and output files are the same
        self.assertTrue(AS2SendReceiveTest.compareFiles(self.payload.file, out_message.payload.file)) 
开发者ID:abhishek-ram,项目名称:pyas2,代码行数:34,代码来源:tests.py

示例12: testEncryptMessageNoMdn

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import make_msgid [as 别名]
def testEncryptMessageNoMdn(self):
        """ Test Permutation 4: Sender sends encrypted data and does NOT request a receipt. """

        # Create the partner with appropriate settings for this case
        partner = models.Partner.objects.create(name='Client Partner',
                                                as2_name='as2server',
                                                target_url='http://localhost:8080/pyas2/as2receive',
                                                compress=False,
                                                encryption='des_ede3_cbc',
                                                encryption_key=self.server_crt,
                                                mdn=False)

        # Build and send the message to server
        message_id = emailutils.make_msgid().strip('<>')
        in_message, response = self.buildSendMessage(message_id, partner)

        # Check if a 200 response was received
        self.assertEqual(response.status_code, 200)

        # Check if message was processed successfully
        out_message = models.Message.objects.get(message_id=message_id)
        self.assertEqual(out_message.status, 'S')

        # Check if input and output files are the same
        # AS2SendReceiveTest.printLogs(out_message)
        self.assertTrue(AS2SendReceiveTest.compareFiles(self.payload.file, out_message.payload.file)) 
开发者ID:abhishek-ram,项目名称:pyas2,代码行数:28,代码来源:tests.py

示例13: testEncryptMessageMdn

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import make_msgid [as 别名]
def testEncryptMessageMdn(self):
        """ Test Permutation 5: Sender sends encrypted data and requests an unsigned receipt. """

        # Create the partner with appropriate settings for this case
        partner = models.Partner.objects.create(name='Client Partner',
                                                as2_name='as2server',
                                                target_url='http://localhost:8080/pyas2/as2receive',
                                                compress=False,
                                                encryption='des_ede3_cbc',
                                                encryption_key=self.server_crt,
                                                mdn=True)

        # Setup the message object and buid the message
        message_id = emailutils.make_msgid().strip('<>')
        in_message, response = self.buildSendMessage(message_id, partner)

        # Check if a 200 response was received
        self.assertEqual(response.status_code, 200)

        # Check if message was processed successfully
        out_message = models.Message.objects.get(message_id=message_id)
        # AS2SendReceiveTest.printLogs(out_message)
        self.assertEqual(out_message.status, 'S')

        # Process the MDN for the in message and check status
        AS2SendReceiveTest.buildMdn(in_message, response)
        # AS2SendReceiveTest.printLogs(in_message)
        self.assertEqual(in_message.status, 'S')

        # Check if input and output files are the same
        self.assertTrue(AS2SendReceiveTest.compareFiles(self.payload.file, out_message.payload.file)) 
开发者ID:abhishek-ram,项目名称:pyas2,代码行数:33,代码来源:tests.py

示例14: testSignMessageNoMdn

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import make_msgid [as 别名]
def testSignMessageNoMdn(self):
        """ Test Permutation 7: Sender sends signed data and does NOT request a receipt. """

        # Create the partner with appropriate settings for this case
        partner = models.Partner.objects.create(name='Client Partner',
                                                as2_name='as2server',
                                                target_url='http://localhost:8080/pyas2/as2receive',
                                                compress=False,
                                                signature='sha1',
                                                signature_key=self.server_crt,
                                                mdn=False)

        # Build and send the message to server
        message_id = emailutils.make_msgid().strip('<>')
        in_message, response = self.buildSendMessage(message_id, partner)

        # Check if a 200 response was received
        self.assertEqual(response.status_code, 200)

        # Check if message was processed successfully
        out_message = models.Message.objects.get(message_id=message_id)
        # AS2SendReceiveTest.printLogs(out_message)
        self.assertEqual(out_message.status, 'S')

        # Check if input and output files are the same
        self.assertTrue(AS2SendReceiveTest.compareFiles(self.payload.file, out_message.payload.file)) 
开发者ID:abhishek-ram,项目名称:pyas2,代码行数:28,代码来源:tests.py

示例15: testSignMessageMdn

# 需要导入模块: from email import utils [as 别名]
# 或者: from email.utils import make_msgid [as 别名]
def testSignMessageMdn(self):
        """ Test Permutation 8: Sender sends signed data and requests an unsigned receipt. """

        # Create the partner with appropriate settings for this case
        partner = models.Partner.objects.create(name='Client Partner',
                                                as2_name='as2server',
                                                target_url='http://localhost:8080/pyas2/as2receive',
                                                compress=False,
                                                signature='sha1',
                                                signature_key=self.server_crt,
                                                mdn=True)

        # Setup the message object and buid the message
        message_id = emailutils.make_msgid().strip('<>')
        in_message, response = self.buildSendMessage(message_id, partner)

        # Check if a 200 response was received
        self.assertEqual(response.status_code, 200)

        # Check if message was processed successfully
        out_message = models.Message.objects.get(message_id=message_id)
        # AS2SendReceiveTest.printLogs(out_message)
        self.assertEqual(out_message.status, 'S')

        # Process the MDN for the in message and check status
        AS2SendReceiveTest.buildMdn(in_message, response)
        # AS2SendReceiveTest.printLogs(in_message)
        self.assertEqual(in_message.status, 'S')

        # Check if input and output files are the same
        self.assertTrue(AS2SendReceiveTest.compareFiles(self.payload.file, out_message.payload.file)) 
开发者ID:abhishek-ram,项目名称:pyas2,代码行数:33,代码来源:tests.py


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