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


Python message.set_payload方法代码示例

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


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

示例1: send

# 需要导入模块: from email import message [as 别名]
# 或者: from email.message import set_payload [as 别名]
def send(
    sender, to,
    subject='None',
    body='None',
    server='localhost'
):
    """sends a message."""
    message = email.message.Message()
    message['To'] = to
    message['From'] = sender
    message['Subject'] = subject
    message.set_payload(body)

    server = smtplib.SMTP(server)
    try:
        return server.sendmail(sender, to, message.as_string())
    finally:
        server.quit() 
开发者ID:PacktPublishing,项目名称:Expert-Python-Programming_Second-Edition,代码行数:20,代码来源:mailer.py

示例2: _get_upload_content

# 需要导入模块: from email import message [as 别名]
# 或者: from email.message import set_payload [as 别名]
def _get_upload_content(field_storage):
  """Returns an `email.Message` that contains the values of the file transfer.

  This method decodes the content of the field storage and creates a new
  `email.Message`.

  Args:
    field_storage: `cgi.FieldStorage` that represents an uploaded blob.

  Returns:
    An `email.message.Message` that lists the upload information.
  """
  message = email.message.Message()
  message.add_header(
      'content-transfer-encoding',
      field_storage.headers.getheader('Content-Transfer-Encoding', ''))
  message.set_payload(field_storage.file.read())
  payload = message.get_payload(decode=True)
  return email.message_from_string(payload) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:21,代码来源:blobstore.py

示例3: test_terminating_newline

# 需要导入模块: from email import message [as 别名]
# 或者: from email.message import set_payload [as 别名]
def test_terminating_newline(self):
        message = email.message.Message()
        message['From'] = 'john@example.com'
        message.set_payload('No newline at the end')
        i = self._box.add(message)

        # A newline should have been appended to the payload
        message = self._box.get(i)
        self.assertEqual(message.get_payload(), 'No newline at the end\n') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_mailbox.py

示例4: compat32_message

# 需要导入模块: from email import message [as 别名]
# 或者: from email.message import set_payload [as 别名]
def compat32_message(request):
    message = email.message.Message()
    message["To"] = email.header.Header("recipient@example.com")
    message["From"] = email.header.Header("sender@example.com")
    message["Subject"] = "A message"
    message.set_payload("Hello World")

    return message 
开发者ID:cole,项目名称:aiosmtplib,代码行数:10,代码来源:conftest.py


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