Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / html / python / lib / module-smtplib.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="module-smtpd.html" />
13<link rel="prev" href="module-nntplib.html" />
14<link rel="parent" href="internet.html" />
15<link rel="next" href="SMTP-objects.html" />
16<meta name='aesop' content='information' />
17<title>11.12 smtplib -- SMTP protocol client</title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="11.11.1 NNTP Objects"
25 href="nntp-objects.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="11. Internet Protocols and"
28 href="internet.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="11.12.1 SMTP Objects"
31 href="SMTP-objects.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python Library Reference</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="nntp-objects.html">11.11.1 NNTP Objects</A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="internet.html">11. Internet Protocols and</A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="SMTP-objects.html">11.12.1 SMTP Objects</A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H1><A NAME="SECTION00131200000000000000000">
5611.12 <tt class="module">smtplib</tt> --
57 SMTP protocol client</A>
58</H1>
59
60<P>
61<A NAME="module-smtplib"></A>
62
63<P>
64<a id='l2h-3487' xml:id='l2h-3487'></a><a id='l2h-3497' xml:id='l2h-3497'></a>
65
66<P>
67The <tt class="module">smtplib</tt> module defines an SMTP client session object that
68can be used to send mail to any Internet machine with an SMTP or ESMTP
69listener daemon. For details of SMTP and ESMTP operation, consult
70<a class="rfc" id='rfcref-90315' xml:id='rfcref-90315'
71href="http://www.faqs.org/rfcs/rfc821.html">RFC 821</a> (<em class="citetitle"
72 >Simple Mail Transfer Protocol</em>) and <a class="rfc" id='rfcref-90317' xml:id='rfcref-90317'
73href="http://www.faqs.org/rfcs/rfc1869.html">RFC 1869</a>
74(<em class="citetitle"
75 >SMTP Service Extensions</em>).
76
77<P>
78<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
79 <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-3488' xml:id='l2h-3488' class="class">SMTP</tt></b>(</nobr></td>
80 <td><var></var><big>[</big><var>host</var><big>[</big><var>, port</var><big>[</big><var>,
81 local_hostname</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
82<dd>
83A <tt class="class">SMTP</tt> instance encapsulates an SMTP connection. It has
84methods that support a full repertoire of SMTP and ESMTP
85operations. If the optional host and port parameters are given, the
86SMTP <tt class="method">connect()</tt> method is called with those parameters during
87initialization. An <tt class="exception">SMTPConnectError</tt> is raised if the
88specified host doesn't respond correctly.
89
90<P>
91For normal use, you should only require the initialization/connect,
92<tt class="method">sendmail()</tt>, and <tt class="method">quit()</tt> methods. An example is
93included below.
94</dl>
95
96<P>
97A nice selection of exceptions is defined as well:
98
99<P>
100<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-3489' xml:id='l2h-3489' class="exception">SMTPException</tt></b></dt>
101<dd>
102 Base exception class for all exceptions raised by this module.
103</dd></dl>
104
105<P>
106<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-3490' xml:id='l2h-3490' class="exception">SMTPServerDisconnected</tt></b></dt>
107<dd>
108 This exception is raised when the server unexpectedly disconnects,
109 or when an attempt is made to use the <tt class="class">SMTP</tt> instance before
110 connecting it to a server.
111</dd></dl>
112
113<P>
114<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-3491' xml:id='l2h-3491' class="exception">SMTPResponseException</tt></b></dt>
115<dd>
116 Base class for all exceptions that include an SMTP error code.
117 These exceptions are generated in some instances when the SMTP
118 server returns an error code. The error code is stored in the
119 <tt class="member">smtp_code</tt> attribute of the error, and the
120 <tt class="member">smtp_error</tt> attribute is set to the error message.
121</dd></dl>
122
123<P>
124<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-3492' xml:id='l2h-3492' class="exception">SMTPSenderRefused</tt></b></dt>
125<dd>
126 Sender address refused. In addition to the attributes set by on all
127 <tt class="exception">SMTPResponseException</tt> exceptions, this sets `sender' to
128 the string that the SMTP server refused.
129</dd></dl>
130
131<P>
132<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-3493' xml:id='l2h-3493' class="exception">SMTPRecipientsRefused</tt></b></dt>
133<dd>
134 All recipient addresses refused. The errors for each recipient are
135 accessible through the attribute <tt class="member">recipients</tt>, which is a
136 dictionary of exactly the same sort as <tt class="method">SMTP.sendmail()</tt>
137 returns.
138</dd></dl>
139
140<P>
141<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-3494' xml:id='l2h-3494' class="exception">SMTPDataError</tt></b></dt>
142<dd>
143 The SMTP server refused to accept the message data.
144</dd></dl>
145
146<P>
147<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-3495' xml:id='l2h-3495' class="exception">SMTPConnectError</tt></b></dt>
148<dd>
149 Error occurred during establishment of a connection with the server.
150</dd></dl>
151
152<P>
153<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-3496' xml:id='l2h-3496' class="exception">SMTPHeloError</tt></b></dt>
154<dd>
155 The server refused our "<tt class="samp">HELO</tt>" message.
156</dd></dl>
157
158<P>
159<div class="seealso">
160 <p class="heading">See Also:</p>
161
162 <dl compact="compact" class="seerfc">
163 <dt><a href="http://www.faqs.org/rfcs/rfc821.html"
164 title="Simple Mail Transfer Protocol"
165 >RFC 821, <em>Simple Mail Transfer Protocol</em></a>
166 <dd>Protocol definition for
167 SMTP. This document covers the model, operating procedure,
168 and protocol details for SMTP.
169 </dl>
170 <dl compact="compact" class="seerfc">
171 <dt><a href="http://www.faqs.org/rfcs/rfc1869.html"
172 title="SMTP Service Extensions"
173 >RFC 1869, <em>SMTP Service Extensions</em></a>
174 <dd>Definition of the ESMTP
175 extensions for SMTP. This describes a framework for
176 extending SMTP with new commands, supporting dynamic
177 discovery of the commands provided by the server, and
178 defines a few additional commands.
179 </dl>
180</div>
181
182<P>
183
184<p><br /></p><hr class='online-navigation' />
185<div class='online-navigation'>
186<!--Table of Child-Links-->
187<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a>
188
189<UL CLASS="ChildLinks">
190<LI><A href="SMTP-objects.html">11.12.1 SMTP Objects</a>
191<LI><A href="SMTP-example.html">11.12.2 SMTP Example</a>
192</ul>
193<!--End of Table of Child-Links-->
194</div>
195
196<DIV CLASS="navigation">
197<div class='online-navigation'>
198<p></p><hr />
199<table align="center" width="100%" cellpadding="0" cellspacing="2">
200<tr>
201<td class='online-navigation'><a rel="prev" title="11.11.1 NNTP Objects"
202 href="nntp-objects.html"><img src='../icons/previous.png'
203 border='0' height='32' alt='Previous Page' width='32' /></A></td>
204<td class='online-navigation'><a rel="parent" title="11. Internet Protocols and"
205 href="internet.html"><img src='../icons/up.png'
206 border='0' height='32' alt='Up One Level' width='32' /></A></td>
207<td class='online-navigation'><a rel="next" title="11.12.1 SMTP Objects"
208 href="SMTP-objects.html"><img src='../icons/next.png'
209 border='0' height='32' alt='Next Page' width='32' /></A></td>
210<td align="center" width="100%">Python Library Reference</td>
211<td class='online-navigation'><a rel="contents" title="Table of Contents"
212 href="contents.html"><img src='../icons/contents.png'
213 border='0' height='32' alt='Contents' width='32' /></A></td>
214<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
215 border='0' height='32' alt='Module Index' width='32' /></a></td>
216<td class='online-navigation'><a rel="index" title="Index"
217 href="genindex.html"><img src='../icons/index.png'
218 border='0' height='32' alt='Index' width='32' /></A></td>
219</tr></table>
220<div class='online-navigation'>
221<b class="navlabel">Previous:</b>
222<a class="sectref" rel="prev" href="nntp-objects.html">11.11.1 NNTP Objects</A>
223<b class="navlabel">Up:</b>
224<a class="sectref" rel="parent" href="internet.html">11. Internet Protocols and</A>
225<b class="navlabel">Next:</b>
226<a class="sectref" rel="next" href="SMTP-objects.html">11.12.1 SMTP Objects</A>
227</div>
228</div>
229<hr />
230<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
231</DIV>
232<!--End of Navigation Panel-->
233<ADDRESS>
234See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
235</ADDRESS>
236</BODY>
237</HTML>