| |
| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| <html><head><title>Python: module gdata.tlslite.integration.SMTP_TLS</title> |
| </head><body bgcolor="#f0f0f8"> |
| |
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> |
| <tr bgcolor="#7799ee"> |
| <td valign=bottom> <br> |
| <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="gdata.html"><font color="#ffffff">gdata</font></a>.<a href="gdata.tlslite.html"><font color="#ffffff">tlslite</font></a>.<a href="gdata.tlslite.integration.html"><font color="#ffffff">integration</font></a>.SMTP_TLS</strong></big></big></font></td |
| ><td align=right valign=bottom |
| ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/usr/local/google/home/afshar/src/external-gdata-release/google3/src/gdata/tlslite/integration/SMTP_TLS.py">/usr/local/google/home/afshar/src/external-gdata-release/google3/src/gdata/tlslite/integration/SMTP_TLS.py</a></font></td></tr></table> |
| <p><tt>TLS Lite + smtplib.</tt></p> |
| <p> |
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| <tr bgcolor="#ee77aa"> |
| <td colspan=3 valign=bottom> <br> |
| <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> |
| |
| <tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> |
| <td width="100%"><dl> |
| <dt><font face="helvetica, arial"><a href="smtplib.html#SMTP">smtplib.SMTP</a> |
| </font></dt><dd> |
| <dl> |
| <dt><font face="helvetica, arial"><a href="gdata.tlslite.integration.SMTP_TLS.html#SMTP_TLS">SMTP_TLS</a> |
| </font></dt></dl> |
| </dd> |
| </dl> |
| <p> |
| <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> |
| <tr bgcolor="#ffc8d8"> |
| <td colspan=3 valign=bottom> <br> |
| <font color="#000000" face="helvetica, arial"><a name="SMTP_TLS">class <strong>SMTP_TLS</strong></a>(<a href="smtplib.html#SMTP">smtplib.SMTP</a>)</font></td></tr> |
| |
| <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> |
| <td colspan=2><tt>This class extends L{smtplib.<a href="smtplib.html#SMTP">SMTP</a>} with TLS support.<br> </tt></td></tr> |
| <tr><td> </td> |
| <td width="100%">Methods defined here:<br> |
| <dl><dt><a name="SMTP_TLS-starttls"><strong>starttls</strong></a>(self, username<font color="#909090">=None</font>, password<font color="#909090">=None</font>, sharedKey<font color="#909090">=None</font>, certChain<font color="#909090">=None</font>, privateKey<font color="#909090">=None</font>, cryptoID<font color="#909090">=None</font>, protocol<font color="#909090">=None</font>, x509Fingerprint<font color="#909090">=None</font>, x509TrustList<font color="#909090">=None</font>, x509CommonName<font color="#909090">=None</font>, settings<font color="#909090">=None</font>)</dt><dd><tt>Puts the connection to the <a href="smtplib.html#SMTP">SMTP</a> server into TLS mode.<br> |
| <br> |
| If the server supports TLS, this will encrypt the rest of the <a href="smtplib.html#SMTP">SMTP</a><br> |
| session.<br> |
| <br> |
| For client authentication, use one of these argument<br> |
| combinations:<br> |
| - username, password (SRP)<br> |
| - username, sharedKey (shared-key)<br> |
| - certChain, privateKey (certificate)<br> |
| <br> |
| For server authentication, you can either rely on the<br> |
| implicit mutual authentication performed by SRP or<br> |
| shared-keys, or you can do certificate-based server<br> |
| authentication with one of these argument combinations:<br> |
| - cryptoID[, protocol] (requires cryptoIDlib)<br> |
| - x509Fingerprint<br> |
| - x509TrustList[, x509CommonName] (requires cryptlib_py)<br> |
| <br> |
| Certificate-based server authentication is compatible with<br> |
| SRP or certificate-based client authentication. It is<br> |
| not compatible with shared-keys.<br> |
| <br> |
| The caller should be prepared to handle TLS-specific<br> |
| exceptions. See the client handshake functions in<br> |
| L{tlslite.TLSConnection.TLSConnection} for details on which<br> |
| exceptions might be raised.<br> |
| <br> |
| @type username: str<br> |
| @param username: SRP or shared-key username. Requires the<br> |
| 'password' or 'sharedKey' argument.<br> |
| <br> |
| @type password: str<br> |
| @param password: SRP password for mutual authentication.<br> |
| Requires the 'username' argument.<br> |
| <br> |
| @type sharedKey: str<br> |
| @param sharedKey: Shared key for mutual authentication.<br> |
| Requires the 'username' argument.<br> |
| <br> |
| @type certChain: L{tlslite.X509CertChain.X509CertChain} or<br> |
| L{cryptoIDlib.CertChain.CertChain}<br> |
| @param certChain: Certificate chain for client authentication.<br> |
| Requires the 'privateKey' argument. Excludes the SRP or<br> |
| shared-key related arguments.<br> |
| <br> |
| @type privateKey: L{tlslite.utils.RSAKey.RSAKey}<br> |
| @param privateKey: Private key for client authentication.<br> |
| Requires the 'certChain' argument. Excludes the SRP or<br> |
| shared-key related arguments.<br> |
| <br> |
| @type cryptoID: str<br> |
| @param cryptoID: cryptoID for server authentication. Mutually<br> |
| exclusive with the 'x509...' arguments.<br> |
| <br> |
| @type protocol: str<br> |
| @param protocol: cryptoID protocol URI for server<br> |
| authentication. Requires the 'cryptoID' argument.<br> |
| <br> |
| @type x509Fingerprint: str<br> |
| @param x509Fingerprint: Hex-encoded X.509 fingerprint for<br> |
| server authentication. Mutually exclusive with the 'cryptoID'<br> |
| and 'x509TrustList' arguments.<br> |
| <br> |
| @type x509TrustList: list of L{tlslite.X509.X509}<br> |
| @param x509TrustList: A list of trusted root certificates. The<br> |
| other party must present a certificate chain which extends to<br> |
| one of these root certificates. The cryptlib_py module must be<br> |
| installed to use this parameter. Mutually exclusive with the<br> |
| 'cryptoID' and 'x509Fingerprint' arguments.<br> |
| <br> |
| @type x509CommonName: str<br> |
| @param x509CommonName: The end-entity certificate's 'CN' field<br> |
| must match this value. For a web server, this is typically a<br> |
| server name such as 'www.amazon.com'. Mutually exclusive with<br> |
| the 'cryptoID' and 'x509Fingerprint' arguments. Requires the<br> |
| 'x509TrustList' argument.<br> |
| <br> |
| @type settings: L{tlslite.HandshakeSettings.HandshakeSettings}<br> |
| @param settings: Various settings which can be used to control<br> |
| the ciphersuites, certificate types, and SSL/TLS versions<br> |
| offered by the client.</tt></dd></dl> |
| |
| <hr> |
| Methods inherited from <a href="smtplib.html#SMTP">smtplib.SMTP</a>:<br> |
| <dl><dt><a name="SMTP_TLS-__init__"><strong>__init__</strong></a>(self, host<font color="#909090">=''</font>, port<font color="#909090">=0</font>, local_hostname<font color="#909090">=None</font>, timeout<font color="#909090">=<object object></font>)</dt><dd><tt>Initialize a new instance.<br> |
| <br> |
| If specified, `host' is the name of the remote host to which to<br> |
| connect. If specified, `port' specifies the port to which to connect.<br> |
| By default, smtplib.SMTP_PORT is used. An SMTPConnectError is raised<br> |
| if the specified `host' doesn't respond correctly. If specified,<br> |
| `local_hostname` is used as the FQDN of the local host. By default,<br> |
| the local hostname is found using socket.getfqdn().</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-close"><strong>close</strong></a>(self)</dt><dd><tt>Close the connection to the <a href="smtplib.html#SMTP">SMTP</a> server.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-connect"><strong>connect</strong></a>(self, host<font color="#909090">='localhost'</font>, port<font color="#909090">=0</font>)</dt><dd><tt>Connect to a host on a given port.<br> |
| <br> |
| If the hostname ends with a colon (`:') followed by a number, and<br> |
| there is no port specified, that suffix will be stripped off and the<br> |
| number interpreted as the port number to use.<br> |
| <br> |
| Note: This method is automatically invoked by __init__, if a host is<br> |
| specified during instantiation.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-data"><strong>data</strong></a>(self, msg)</dt><dd><tt><a href="smtplib.html#SMTP">SMTP</a> 'DATA' command -- sends message data to server.<br> |
| <br> |
| Automatically quotes lines beginning with a period per rfc821.<br> |
| Raises SMTPDataError if there is an unexpected reply to the<br> |
| DATA command; the return value from this method is the final<br> |
| response code received when the all data is sent.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-docmd"><strong>docmd</strong></a>(self, cmd, args<font color="#909090">=''</font>)</dt><dd><tt>Send a command, and return its response code.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-ehlo"><strong>ehlo</strong></a>(self, name<font color="#909090">=''</font>)</dt><dd><tt><a href="smtplib.html#SMTP">SMTP</a> 'ehlo' command.<br> |
| Hostname to send for this command defaults to the FQDN of the local<br> |
| host.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-ehlo_or_helo_if_needed"><strong>ehlo_or_helo_if_needed</strong></a>(self)</dt><dd><tt>Call <a href="#SMTP_TLS-ehlo_msg">ehlo</a>() and/or <a href="#SMTP_TLS-helo">helo</a>() if needed.<br> |
| <br> |
| If there has been no previous EHLO or HELO command this session, this<br> |
| method tries ESMTP EHLO first.<br> |
| <br> |
| This method may raise the following exceptions:<br> |
| <br> |
| SMTPHeloError The server didn't reply properly to<br> |
| the helo greeting.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-expn"><strong>expn</strong></a>(self, address)</dt><dd><tt><a href="smtplib.html#SMTP">SMTP</a> 'expn' command -- expands a mailing list.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-getreply"><strong>getreply</strong></a>(self)</dt><dd><tt>Get a reply from the server.<br> |
| <br> |
| Returns a tuple consisting of:<br> |
| <br> |
| - server response code (e.g. '250', or such, if all goes well)<br> |
| Note: returns -1 if it can't read response code.<br> |
| <br> |
| - server response string corresponding to response code (multiline<br> |
| responses are converted to a single, multiline string).<br> |
| <br> |
| Raises SMTPServerDisconnected if end-of-file is reached.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-has_extn"><strong>has_extn</strong></a>(self, opt)</dt><dd><tt>Does the server support a given <a href="smtplib.html#SMTP">SMTP</a> service extension?</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-helo"><strong>helo</strong></a>(self, name<font color="#909090">=''</font>)</dt><dd><tt><a href="smtplib.html#SMTP">SMTP</a> 'helo' command.<br> |
| Hostname to send for this command defaults to the FQDN of the local<br> |
| host.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-help"><strong>help</strong></a>(self, args<font color="#909090">=''</font>)</dt><dd><tt><a href="smtplib.html#SMTP">SMTP</a> 'help' command.<br> |
| Returns help text from server.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-login"><strong>login</strong></a>(self, user, password)</dt><dd><tt>Log in on an <a href="smtplib.html#SMTP">SMTP</a> server that requires authentication.<br> |
| <br> |
| The arguments are:<br> |
| - user: The user name to authenticate with.<br> |
| - password: The password for the authentication.<br> |
| <br> |
| If there has been no previous EHLO or HELO command this session, this<br> |
| method tries ESMTP EHLO first.<br> |
| <br> |
| This method will return normally if the authentication was successful.<br> |
| <br> |
| This method may raise the following exceptions:<br> |
| <br> |
| SMTPHeloError The server didn't reply properly to<br> |
| the helo greeting.<br> |
| SMTPAuthenticationError The server didn't accept the username/<br> |
| password combination.<br> |
| SMTPException No suitable authentication method was<br> |
| found.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-mail"><strong>mail</strong></a>(self, sender, options<font color="#909090">=[]</font>)</dt><dd><tt><a href="smtplib.html#SMTP">SMTP</a> 'mail' command -- begins mail xfer session.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-noop"><strong>noop</strong></a>(self)</dt><dd><tt><a href="smtplib.html#SMTP">SMTP</a> 'noop' command -- doesn't do anything :></tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-putcmd"><strong>putcmd</strong></a>(self, cmd, args<font color="#909090">=''</font>)</dt><dd><tt>Send a command to the server.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-quit"><strong>quit</strong></a>(self)</dt><dd><tt>Terminate the <a href="smtplib.html#SMTP">SMTP</a> session.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-rcpt"><strong>rcpt</strong></a>(self, recip, options<font color="#909090">=[]</font>)</dt><dd><tt><a href="smtplib.html#SMTP">SMTP</a> 'rcpt' command -- indicates 1 recipient for this mail.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-rset"><strong>rset</strong></a>(self)</dt><dd><tt><a href="smtplib.html#SMTP">SMTP</a> 'rset' command -- resets session.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-send"><strong>send</strong></a>(self, str)</dt><dd><tt>Send `str' to the server.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-sendmail"><strong>sendmail</strong></a>(self, from_addr, to_addrs, msg, mail_options<font color="#909090">=[]</font>, rcpt_options<font color="#909090">=[]</font>)</dt><dd><tt>This command performs an entire mail transaction.<br> |
| <br> |
| The arguments are:<br> |
| - from_addr : The address sending this mail.<br> |
| - to_addrs : A list of addresses to send this mail to. A bare<br> |
| string will be treated as a list with 1 address.<br> |
| - msg : The message to send.<br> |
| - mail_options : List of ESMTP options (such as 8bitmime) for the<br> |
| mail command.<br> |
| - rcpt_options : List of ESMTP options (such as DSN commands) for<br> |
| all the rcpt commands.<br> |
| <br> |
| If there has been no previous EHLO or HELO command this session, this<br> |
| method tries ESMTP EHLO first. If the server does ESMTP, message size<br> |
| and each of the specified options will be passed to it. If EHLO<br> |
| fails, HELO will be tried and ESMTP options suppressed.<br> |
| <br> |
| This method will return normally if the mail is accepted for at least<br> |
| one recipient. It returns a dictionary, with one entry for each<br> |
| recipient that was refused. Each entry contains a tuple of the <a href="smtplib.html#SMTP">SMTP</a><br> |
| error code and the accompanying error message sent by the server.<br> |
| <br> |
| This method may raise the following exceptions:<br> |
| <br> |
| SMTPHeloError The server didn't reply properly to<br> |
| the helo greeting.<br> |
| SMTPRecipientsRefused The server rejected ALL recipients<br> |
| (no mail was sent).<br> |
| SMTPSenderRefused The server didn't accept the from_addr.<br> |
| SMTPDataError The server replied with an unexpected<br> |
| error code (other than a refusal of<br> |
| a recipient).<br> |
| <br> |
| Note: the connection will be open even after an exception is raised.<br> |
| <br> |
| Example:<br> |
| <br> |
| >>> import smtplib<br> |
| >>> s=smtplib.<a href="smtplib.html#SMTP">SMTP</a>("localhost")<br> |
| >>> tolist=["one@one.org","two@two.org","three@three.org","four@four.org"]<br> |
| >>> msg = '''\<br> |
| ... From: Me@my.org<br> |
| ... Subject: testin'...<br> |
| ...<br> |
| ... This is a test '''<br> |
| >>> s.<a href="#SMTP_TLS-sendmail">sendmail</a>("me@my.org",tolist,msg)<br> |
| { "three@three.org" : ( 550 ,"User unknown" ) }<br> |
| >>> s.<a href="#SMTP_TLS-quit">quit</a>()<br> |
| <br> |
| In the above example, the message was accepted for delivery to three<br> |
| of the four addresses, and one was rejected, with the error code<br> |
| 550. If all addresses are accepted, then the method will return an<br> |
| empty dictionary.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-set_debuglevel"><strong>set_debuglevel</strong></a>(self, debuglevel)</dt><dd><tt>Set the debug output level.<br> |
| <br> |
| A non-false value results in debug messages for connection and for all<br> |
| messages sent to and received from the server.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-verify"><strong>verify</strong></a>(self, address)</dt><dd><tt><a href="smtplib.html#SMTP">SMTP</a> 'verify' command -- checks for address validity.</tt></dd></dl> |
| |
| <dl><dt><a name="SMTP_TLS-vrfy"><strong>vrfy</strong></a> = verify(self, address)</dt><dd><tt><a href="smtplib.html#SMTP">SMTP</a> 'verify' command -- checks for address validity.</tt></dd></dl> |
| |
| <hr> |
| Data and other attributes inherited from <a href="smtplib.html#SMTP">smtplib.SMTP</a>:<br> |
| <dl><dt><strong>debuglevel</strong> = 0</dl> |
| |
| <dl><dt><strong>default_port</strong> = 25</dl> |
| |
| <dl><dt><strong>does_esmtp</strong> = 0</dl> |
| |
| <dl><dt><strong>ehlo_msg</strong> = 'ehlo'</dl> |
| |
| <dl><dt><strong>ehlo_resp</strong> = None</dl> |
| |
| <dl><dt><strong>file</strong> = None</dl> |
| |
| <dl><dt><strong>helo_resp</strong> = None</dl> |
| |
| </td></tr></table></td></tr></table> |
| </body></html> |