-=[ Mr. Bumblebee ]=-
_Indonesia_
σ
'ώDSc @@ s d Z d d l m Z d d l m Z m Z m Z m Z m Z d d l m
Z d d l m
Z
d d l m Z d e f d YZ d S(
sA A convenience class around email.Message and email.MIMEMultipart.i ( t absolute_import( t Headert Messaget
MIMEMultipartt MIMETextt Utils( t __version__( t safe_unicode( t SMTPConnectiont EmailMessagec B@ s e Z d Z d d Z d d d Z d d Z e Z d d Z d Z d Z
e d d d d Z e d Z
e d
Z RS( sf An email message.
The constructor needs an origin address, a destination address or addresses
and a subject, and accepts a body as well. Add additional parts to the
message with add_inline_attachment(). Retrieve the entire formatted message
with as_string().
Headers can be accessed with get() and msg[], and modified with msg[] =.
c C@ sΐ i | _ | | _ g | _ t | t r6 | g } n g } x$ | D] } | j | j | qC Wd j | | j d <| j | | j d <t j t | | j d <d t
| j d <d S( s| Create an email message.
:param from_address: The origin address, to be put on the From header.
:param to_address: The destination address of the message, to be put in
the To header. Can also be a list of addresses.
:param subject: The subject of the message.
:param body: If given, the body of the message.
All four parameters can be unicode strings or byte strings, but for the
addresses and subject byte strings must be encoded in UTF-8. For the
body any byte string will be accepted; if it's not ASCII or UTF-8,
it'll be sent with charset=8-bit.
s , t Tot Fromt Subjects Bazaar (%s)s
User-AgentN( t _headerst _bodyt _partst
isinstancet
basestringt appendt address_to_encoded_headert joinR R t _bzrlib_version( t selft from_addresst
to_addresst subjectt bodyt to_addressest addr( ( s8 /usr/lib/python2.7/dist-packages/bzrlib/email_message.pyt __init__- s
t plainc C@ sT | j d k r7 | j j | j d d f d | _ n | j j | | | f d S( sV Add an inline attachment to the message.
:param body: A text to attach. Can be an unicode string or a byte
string, and it'll be sent as ascii, utf-8, or 8-bit, in that
preferred order.
:param filename: The name for the attachment. This will give a default
name for email programs to save the attachment.
:param mime_subtype: MIME subtype of the attachment (eg. 'plain' for
text/plain [default]).
The attachment body will be displayed inline, so do not use this
function to attach binary attachments.
R N( R t NoneR R ( R R t filenamet mime_subtype( ( s8 /usr/lib/python2.7/dist-packages/bzrlib/email_message.pyt add_inline_attachmentL s c C@ sI | j sR t j } | j d k r| j | j \ } } | j | | qn½ t j } | d k rz | j | n x | j D] \ } } } | j | \ } } t j | | | } | d k rτ | d } | d | 7} | j d | n d | d <| j
| q Wx- t | j j
D] \ } }
|
| | <q%W| j S( s¦ Return the entire formatted message as a string.
:param boundary: The boundary to use between MIME parts, if applicable.
Used for tests.
s Content-Types ; name="%s"t inlines Content-DispositionN( R R R R t string_with_encodingt set_payloadR t set_boundaryR t replace_headert attacht sortedR
t itemst as_string( R t boundaryt msgobjR t encodingR R! t payloadt content_typet headert value( ( s8 /usr/lib/python2.7/dist-packages/bzrlib/email_message.pyR+ b s(
"c C@ s | j j | | S( s@ Get a header from the message, returning failobj if not present.( R
t get( R R1 t failobj( ( s8 /usr/lib/python2.7/dist-packages/bzrlib/email_message.pyR3 s c C@ s | j j | d S( sΐ Get a header from the message, returning None if not present.
This method intentionally does not raise KeyError to mimic the behavior
of __getitem__ in email.Message.
N( R
R3 R ( R R1 ( ( s8 /usr/lib/python2.7/dist-packages/bzrlib/email_message.pyt __getitem__ s c C@ s | j j | | S( N( R
t __setitem__( R R1 R2 ( ( s8 /usr/lib/python2.7/dist-packages/bzrlib/email_message.pyR6 s c C@ sN t | | | | } | d k r7 | j | | | n t | j | d S( s Create an email message and send it with SMTPConnection.
:param config: config object to pass to SMTPConnection constructor.
See EmailMessage.__init__() and EmailMessage.add_inline_attachment()
for an explanation of the rest of parameters.
N( R R R"