Changeset 391 for python/trunk/Doc/library/email.mime.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/library/email.mime.rst
r2 r391 1 :mod:`email `: Creating email and MIME objects from scratch2 ---------------------------------------------------------- 1 :mod:`email.mime`: Creating email and MIME objects from scratch 2 --------------------------------------------------------------- 3 3 4 4 .. module:: email.mime … … 36 36 or :mimetype:`image`), and *_subtype* is the :mailheader:`Content-Type` minor 37 37 type (e.g. :mimetype:`plain` or :mimetype:`gif`). *_params* is a parameter 38 key/value dictionary and is passed directly to :meth:`Message.add_header`. 38 key/value dictionary and is passed directly to :meth:`Message.add_header 39 <email.message.Message.add_header>`. 39 40 40 41 The :class:`MIMEBase` class always adds a :mailheader:`Content-Type` header … … 51 52 A subclass of :class:`~email.mime.base.MIMEBase`, this is an intermediate base 52 53 class for MIME messages that are not :mimetype:`multipart`. The primary 53 purpose of this class is to prevent the use of the :meth:`attach` method, 54 which only makes sense for :mimetype:`multipart` messages. If :meth:`attach` 54 purpose of this class is to prevent the use of the 55 :meth:`~email.message.Message.attach` method, which only makes sense for 56 :mimetype:`multipart` messages. If :meth:`~email.message.Message.attach` 55 57 is called, a :exc:`~email.errors.MultipartConversionError` exception is raised. 56 58 … … 77 79 *_subparts* is a sequence of initial subparts for the payload. It must be 78 80 possible to convert this sequence to a list. You can always attach new subparts 79 to the message by using the :meth:`Message.attach` method. 81 to the message by using the :meth:`Message.attach 82 <email.message.Message.attach>` method. 80 83 81 84 Additional parameters for the :mailheader:`Content-Type` header are taken from … … 100 103 Optional *_encoder* is a callable (i.e. function) which will perform the actual 101 104 encoding of the data for transport. This callable takes one argument, which is 102 the :class:`MIMEApplication` instance. It should use :meth:`get_payload` and 103 :meth:`set_payload` to change the payload to encoded form. It should also add 105 the :class:`MIMEApplication` instance. It should use 106 :meth:`~email.message.Message.get_payload` and 107 :meth:`~email.message.Message.set_payload` to change the payload to encoded 108 form. It should also add 104 109 any :mailheader:`Content-Transfer-Encoding` or other headers to the message 105 110 object as necessary. The default encoding is base64. See the … … 128 133 Optional *_encoder* is a callable (i.e. function) which will perform the actual 129 134 encoding of the audio data for transport. This callable takes one argument, 130 which is the :class:`MIMEAudio` instance. It should use :meth:`get_payload` and 131 :meth:`set_payload` to change the payload to encoded form. It should also add 135 which is the :class:`MIMEAudio` instance. It should use 136 :meth:`~email.message.Message.get_payload` and 137 :meth:`~email.message.Message.set_payload` to change the payload to encoded 138 form. It should also add 132 139 any :mailheader:`Content-Transfer-Encoding` or other headers to the message 133 140 object as necessary. The default encoding is base64. See the … … 154 161 Optional *_encoder* is a callable (i.e. function) which will perform the actual 155 162 encoding of the image data for transport. This callable takes one argument, 156 which is the :class:`MIMEImage` instance. It should use :meth:`get_payload` and 157 :meth:`set_payload` to change the payload to encoded form. It should also add 163 which is the :class:`MIMEImage` instance. It should use 164 :meth:`~email.message.Message.get_payload` and 165 :meth:`~email.message.Message.set_payload` to change the payload to encoded 166 form. It should also add 158 167 any :mailheader:`Content-Transfer-Encoding` or other headers to the message 159 168 object as necessary. The default encoding is base64. See the … … 192 201 set of the text and is passed as a parameter to the 193 202 :class:`~email.mime.nonmultipart.MIMENonMultipart` constructor; it defaults 194 to ``us-ascii``. No guessing or encoding is performed on the text data. 203 to ``us-ascii``. If *_text* is unicode, it is encoded using the 204 *output_charset* of *_charset*, otherwise it is used as-is. 195 205 196 206 .. versionchanged:: 2.4 197 The previously deprecated *_encoding* argument has been removed. Encoding 198 happens implicitly based on the *_charset* argument. 199 207 The previously deprecated *_encoding* argument has been removed. Content 208 Transfer Encoding now happens implicitly based on the *_charset* 209 argument. 210 211 Unless the ``_charset`` parameter is explicitly set to ``None``, the 212 MIMEText object created will have both a :mailheader:`Content-Type` header 213 with a ``charset`` parameter, and a :mailheader:`Content-Transfer-Endcoding` 214 header. This means that a subsequent ``set_payload`` call will not result 215 in an encoded payload, even if a charset is passed in the ``set_payload`` 216 command. You can "reset" this behavior by deleting the 217 ``Content-Transfer-Encoding`` header, after which a ``set_payload`` call 218 will automatically encode the new payload (and add a new 219 :mailheader:`Content-Transfer-Encoding` header).
Note:
See TracChangeset
for help on using the changeset viewer.