N
๘๙O5c       sS   d  Z  k Z k Z k Z d Z d Z d Z d Z d Z d Z	 d f  d     YZ
 d	 S(
   sเ  SMTP Client class.

Author: The Dragon De Monsyne <dragondm@integral.org>

(This was modified from the Python 1.5 library HTTP lib.)

This should follow RFC 821. (it dosen't do esmtp (yet))

Example:

>>> import smtplib
>>> s=smtplib.SMTP("localhost")
>>> print s.help()
This is Sendmail version 8.8.4
Topics:
    HELO    EHLO    MAIL    RCPT    DATA
    RSET    NOOP    QUIT    HELP    VRFY
    EXPN    VERB    ETRN    DSN
For more info use "HELP <topic>".
To report bugs in the implementation send email to
    sendmail-bugs@sendmail.org.
For local information send email to Postmaster at your site.
End of HELP info
>>> s.putcmd("vrfy","someone@here")
>>> s.getreply()
(250, "Somebody OverHere <somebody@here.my.org>")
>>> s.quit()

i   s   
s   Server not connecteds   Sender address refuseds   All Recipients refuseds    Error transmoitting message datas   SMTPc      sน   d  Z  d d d  Z d   Z d d d  Z d   Z d d  Z d	   Z d d
  Z d d  Z d d  Z	 d   Z
 d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s2   This class manages a connection to an SMTP server.c    s:   d |  _ t |  _ t |  _ | o |  i | |  n d S(   s์   Initialize a new instance.

        If specified, `host' is the name of the remote host to which
        to connect.  If specified, `port' specifies the port to which
        to connect.  By default, smtplib.SMTP_PORT is used.

        i    N(   s   selfs
   debuglevels   Nones   files	   helo_resps   hosts   connects   port(   s   selfs   hosts   ports1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   __init__. s     			 s    i    c    s   | |  _  d S(   sฌ   Set the debug output level.

        A non-false value results in debug messages for connection and
        for all messages sent to and received from the server.

        N(   s
   debuglevels   self(   s   selfs
   debuglevels1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   set_debuglevel; s     c    s  | o} t i | d  } | d j oZ | |  | | d f \ } } y t i |  } Wn" t i j
 o t i d  n Xn n | o
 t	 } n t i t i
 t i  |  _ |  i d j o d G| | f GHn |  i i | |  |  i   \ } } |  i d j o d G| GHn | Sd S(   sญ   Connect to a host on a given port.
          
        Note:  This method is automatically invoked by __init__,
        if a host is specified during instantiation.

        s   :i    i   s   nonnumeric ports   connect:N(   s   ports   strings   finds   hosts   is   atois
   atoi_errors   sockets   errors	   SMTP_PORTs   AF_INETs   SOCK_STREAMs   selfs   socks
   debuglevels   connects   getreplys   codes   msg(   s   selfs   hosts   ports   is   codes   msgs1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   connectD s&       
  s	   localhostc    sF   |  i d j o d G| GHn |  i o |  i i |  n t  d S(   s   Send `str' to the server.i    s   send:N(   s   selfs
   debuglevels   strs   socks   sends   SMTPServerDisconnected(   s   selfs   strs1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   sendZ s      
c    s$   d | | t f } |  i |  d S(   s&   Send a command to the server.
        s   %s %s%sN(   s   cmds   argss   CRLFs   strs   selfs   send(   s   selfs   cmds   argss   strs1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   putcmdb s     c    s  g  } |  i i d  |  _ xv d on |  i i   } |  i d j o d G| GHn | i t	 i
 | d   | d  } | d d !d j o Pn q Wy t	 i |  } Wn t j
 o d } n Xt	 i | d  } |  i d j o d	 | | f GHn | | f Sd
 S(   s~  Get a reply from the server.
        
        Returns a tuple consisting of:
        - server response code (e.g. '250', or such, if all goes well)
          Note: returns -1 if it can't read responce code.
        - server response string corresponding to response code
                (note : multiline responces converted to a single, 
                 multiline string)
        s   rbi   i    s   reply:i   i   s   -s   
s   reply: retcode (%s); Msg: %sN(   s   resps   selfs   socks   makefiles   files   readlines   lines
   debuglevels   appends   strings   strips   codes   atois   errcodes
   ValueErrors   joins   errmsg(   s   selfs   resps   lines   codes   errcodes   errmsgs1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   getreplyh s(    	   

c    s*   |  i | |  |  i   \ } } | Sd S(   s/    Send a command, and return it's responce code N(   s   selfs   putcmds   cmds   argss   getreplys   codes   msg(   s   selfs   cmds   argss   codes   msgs1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   docmd s     c    sr   t  i |  } t |  d j o t i t i    d } n |  i d |  |  i	   \ } } | |  _ | Sd S(   si    SMTP 'helo' command. Hostname to send for this command  
        defaults to the FQDN of the local host i    s   heloN(   s   strings   strips   names   lens   sockets   gethostbyaddrs   gethostnames   selfs   putcmds   getreplys   codes   msgs	   helo_resp(   s   selfs   names   codes   msgs1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   helo s     	c    s*   |  i d |  |  i   \ } } | Sd S(   s4    SMTP 'help' command. Returns help text from server s   helpN(   s   selfs   putcmds   argss   getreplys   codes   msg(   s   selfs   argss   codes   msgs1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   help s     c    s   |  i d  } | Sd S(   s&    SMTP 'rset' command. Resets session. s   rsetN(   s   selfs   docmds   code(   s   selfs   codes1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   rset s     c    s   |  i d  } | Sd S(   s-    SMTP 'noop' command. Dosen't do anything :> s   noopN(   s   selfs   docmds   code(   s   selfs   codes1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   noopค s     c    s"   |  i d d |  |  i   Sd S(   s0    SMTP 'mail' command. Begins mail xfer session. s   mails   from: %sN(   s   selfs   putcmds   senders   getreply(   s   selfs   senders1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   mailฉ s     c    s"   |  i d d |  |  i   Sd S(   s;    SMTP 'rcpt' command. Indicates 1 recipient for this mail. s   rcpts   to: %sN(   s   selfs   putcmds   recips   getreply(   s   selfs   recips1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   rcptฎ s     c    sโ   t  i d t  i  } d   } t  i | | |  } |  i d  |  i	   \ } } |  i d j o d G| | f GHn | d j o	 d SnT |  i |  |  i d  |  i	   \ } } |  i d j o d G| | f GHn | Sd	 S(
   s    SMTP 'DATA' command. Sends message data to server. 
            Automatically quotes lines beginning with a period per rfc821 s   ^[.]+c    s   d |  i d  Sd  S(   Ns   .i    (   s   pats   group(   s   pats1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   mพ s    s   datai    s   data:ib  i   s   
.
N(   s   res   compiles   Ms   quotepats   ms   subs   msgs   selfs   putcmds   getreplys   codes   repls
   debuglevels   send(   s   selfs   msgs   quotepats   ms   codes   repls1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   dataณ s      	 	 c    s  |  i o |  i   n |  i |  \ } } | d j o |  i   t  n h  } xS | d rI } |  i |  \ } } | d j o
 | d j o | | f | | <n q^ Wt |  t |  j o |  i   t  n |  i |  } | d j o |  i   t  n | Sd S(   sw   This command performs an entire mail transaction. 
            The arguments are: 
               - from_addr : The address sending this mail.
               - to_addrs :  a list of addresses to send this mail to
               - msg : the message to send. 

        This method will return normally if the mail is accepted for at least 
        one recipiant.
        Otherwise it will throw an exception (either SMTPSenderRefused,
          SMTPRecipientsRefused, or SMTPDataError)

        That is, if this method does not throw an exception, then someone 
        should get your mail.

        It returns a dictionary , with one entry for each recipient that was 
        refused. 

        example:
      
         >>> import smtplib
         >>> s=smtplib.SMTP("localhost")
         >>> tolist=["one@one.org","two@two.org","three@three.org","four@four.org"]
         >>> msg = '''
         ... From: Me@my.org
         ... Subject: testin'...
         ...
         ... This is a test '''
         >>> s.sendmail("me@my.org",tolist,msg)
         { "three@three.org" : ( 550 ,"User unknown" ) }
         >>> s.quit()
        
         In the above example, the message was accepted for delivery to 
         three of the four addresses, and one was rejected, with the error
         code 550. If all addresses are accepted, then the method
         will return an empty dictionary.  
         i๚   i    i๛   N(   s   selfs	   helo_resps   helos   mails	   from_addrs   codes   resps   rsets   SMTPSenderRefuseds   senderrss   to_addrss   eachs   rcpts   lens   SMTPRecipientsRefuseds   datas   msgs   SMTPDataError(   s   selfs	   from_addrs   to_addrss   msgs   codes   resps   senderrss   eachs1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   sendmailฮ s*    $ 

	 



c    sL   |  i o |  i i   n t |  _ |  i o |  i i   n t |  _ d S(   s(   Close the connection to the SMTP server.N(   s   selfs   files   closes   Nones   sock(   s   selfs1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   closes     
	
c    s   |  i d  |  i   d  S(   Ns   quit(   s   selfs   docmds   close(   s   selfs1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   quits    (   s   __doc__s   __init__s   set_debuglevels   connects   sends   putcmds   getreplys   docmds   helos   helps   rsets   noops   mails   rcpts   datas   sendmails   closes   quit(    s1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   SMTP+ s$    										=	
N(   s   __doc__s   sockets   strings   res	   SMTP_PORTs   CRLFs   SMTPServerDisconnecteds   SMTPSenderRefuseds   SMTPRecipientsRefuseds   SMTPDataErrors   SMTP(    s1   /var/tmp/python-root/usr/lib/python1.5/smtplib.pys   ? s   