Python email.message.set_payload() Examples
The following are 17
code examples of email.message.set_payload().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
email.message
, or try the search function
.
Example #1
Source File: mailer.py From Expert-Python-Programming_Second-Edition with BSD 3-Clause "New" or "Revised" License | 6 votes |
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()
Example #2
Source File: mailer.py From Expert-Python-Programming_Second-Edition with BSD 3-Clause "New" or "Revised" License | 6 votes |
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()
Example #3
Source File: mailer.py From Expert-Python-Programming_Second-Edition with BSD 3-Clause "New" or "Revised" License | 6 votes |
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()
Example #4
Source File: blobstore.py From python-compat-runtime with Apache License 2.0 | 6 votes |
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)
Example #5
Source File: mailer.py From Expert-Python-Programming-Third-Edition with MIT License | 6 votes |
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()
Example #6
Source File: mailer.py From Expert-Python-Programming-Third-Edition with MIT License | 6 votes |
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()
Example #7
Source File: mailer.py From Expert-Python-Programming-Third-Edition with MIT License | 6 votes |
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()
Example #8
Source File: test_mailbox.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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')
Example #9
Source File: test_mailbox.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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')
Example #10
Source File: test_mailbox.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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')
Example #11
Source File: test_mailbox.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
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')
Example #12
Source File: conftest.py From aiosmtplib with MIT License | 5 votes |
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
Example #13
Source File: test_mailbox.py From ironpython3 with Apache License 2.0 | 5 votes |
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')
Example #14
Source File: test_mailbox.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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')
Example #15
Source File: test_mailbox.py From oss-ftp with MIT License | 5 votes |
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')
Example #16
Source File: test_mailbox.py From BinderFilter with MIT License | 5 votes |
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')
Example #17
Source File: test_mailbox.py From ironpython2 with Apache License 2.0 | 5 votes |
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')