• Home
  • Raw
  • Download

Lines Matching refs:SMTP

1 :mod:`smtplib` --- SMTP protocol client
5 :synopsis: SMTP protocol client (requires sockets).
12 pair: SMTP; protocol
17 The :mod:`smtplib` module defines an SMTP client session object that can be used
18 to send mail to any internet machine with an SMTP or ESMTP listener daemon. For
19 details of SMTP and ESMTP operation, consult :rfc:`821` (Simple Mail Transfer
20 Protocol) and :rfc:`1869` (SMTP Service Extensions).
23 .. class:: SMTP(host='', port=0, local_hostname=None[, timeout], source_address=None)
25 An :class:`SMTP` instance encapsulates an SMTP connection. It has methods
26 that support a full repertoire of SMTP and ESMTP operations. If the optional
27 host and port parameters are given, the SMTP :meth:`connect` method is
44 :meth:`sendmail`, and :meth:`SMTP.quit` methods.
47 The :class:`SMTP` class supports the :keyword:`with` statement. When used
48 like this, the SMTP ``QUIT`` command is issued automatically when the
51 >>> from smtplib import SMTP
52 >>> with SMTP("domain.org") as smtp:
58 .. audit-event:: smtplib.send self,data smtplib.SMTP
61 ``smtplib.SMTP.send`` with arguments ``self`` and ``data``,
82 :class:`SMTP`. :class:`SMTP_SSL` should be used for situations where SSL is
85 *port* is zero, the standard SMTP-over-SSL port (465) is used. The optional
87 meaning as they do in the :class:`SMTP` class. *context*, also optional,
122 standard SMTP client. It's common to use Unix sockets for LMTP, so our
125 same meaning as they do in the :class:`SMTP` class. To specify a Unix
128 Authentication is supported, using the regular SMTP mechanism. When using a
151 attempt is made to use the :class:`SMTP` instance before connecting it to a
157 Base class for all exceptions that include an SMTP error code. These exceptions
158 are generated in some instances when the SMTP server returns an error code. The
167 the SMTP server refused.
174 same sort as :meth:`SMTP.sendmail` returns.
179 The SMTP server refused to accept the message data.
201 SMTP authentication went wrong. Most probably the server didn't accept the
208 Protocol definition for SMTP. This document covers the model, operating
209 procedure, and protocol details for SMTP.
211 :rfc:`1869` - SMTP Service Extensions
212 Definition of the ESMTP extensions for SMTP. This describes a framework for
213 extending SMTP with new commands, supporting dynamic discovery of the commands
219 SMTP Objects
222 An :class:`SMTP` instance has the following methods:
225 .. method:: SMTP.set_debuglevel(level)
235 .. method:: SMTP.docmd(cmd, args='')
251 .. method:: SMTP.connect(host='localhost', port=0)
254 host at the standard SMTP port (25). If the hostname ends with a colon (``':'``)
261 .. audit-event:: smtplib.connect self,host,port smtplib.SMTP.connect
264 .. method:: SMTP.helo(name='')
266 Identify yourself to the SMTP server using ``HELO``. The hostname argument
275 .. method:: SMTP.ehlo(name='')
284 of the SMTP service extensions this server supports, and their parameters
291 .. method:: SMTP.ehlo_or_helo_if_needed()
300 .. method:: SMTP.has_extn(name)
302 Return :const:`True` if *name* is in the set of SMTP service extensions returned
306 .. method:: SMTP.verify(address)
308 Check the validity of an address on this server using SMTP ``VRFY``. Returns a
310 name) if the user address is valid. Otherwise returns an SMTP error code of 400
315 Many sites disable SMTP ``VRFY`` in order to foil spammers.
318 .. method:: SMTP.login(user, password, *, initial_response_ok=True)
320 Log in on an SMTP server that requires authentication. The arguments are the
353 .. method:: SMTP.auth(mechanism, authobject, *, initial_response_ok=True)
355 Issue an ``SMTP`` ``AUTH`` command for the specified authentication
380 The ``SMTP`` class provides ``authobjects`` for the ``CRAM-MD5``, ``PLAIN``,
381 and ``LOGIN`` mechanisms; they are named ``SMTP.auth_cram_md5``,
382 ``SMTP.auth_plain``, and ``SMTP.auth_login`` respectively. They all require
383 that the ``user`` and ``password`` properties of the ``SMTP`` instance are
395 .. method:: SMTP.starttls(keyfile=None, certfile=None, context=None)
397 Put the SMTP connection in TLS (Transport Layer Security) mode. All SMTP
441 .. method:: SMTP.sendmail(from_addr, to_addrs, msg, mail_options=(), rcpt_options=())
473 recipient that was refused. Each entry contains a tuple of the SMTP error code
512 .. method:: SMTP.send_message(msg, from_addr=None, to_addrs=None, \
550 .. method:: SMTP.quit()
552 Terminate the SMTP session and close the connection. Return the result of
553 the SMTP ``QUIT`` command.
556 Low-level methods corresponding to the standard SMTP/ESMTP commands ``HELP``,
564 SMTP Example
596 server = smtplib.SMTP('localhost')
605 via :meth:`~smtplib.SMTP.send_message`; see :ref:`email-examples`.