On this page
smtplib.SMTP_SSL
Prev: smtplib.SMTP | Up: smtplib | Next: smtplib.SMTPAuthenticationError
Rel: smtplib.quoteaddr, smtplib.quotedata, smtplib.SMTP, smtplib.SMTPAuthenticationError
Ref: docs.python.org — smtplib.SMTP_SSL
Tags: #public #python3 #stdlib #smtplib
Import
import smtplib
from smtplib import SMTP_SSL
Signature & Overview
smtplib.SMTP_SSL(host='', port=0, local_hostname=None, *, timeout=<object object at 0x1040b4980>, source_address=None, context=None)
This is a subclass derived from SMTP that connects over an SSL encrypted socket (to use this class you need a socket module that was compiled with SSL support). If host is not specified, '' (the local
Methods & Attributes
SMTP_SSL.auth(self, mechanism, authobject, *, initial_response_ok=True)— Authentication command - requires response processing.SMTP_SSL.auth_cram_md5(self, challenge=None)— Authobject to use with CRAM-MD5 authentication. Requires self.user and self.password to be set.SMTP_SSL.auth_login(self, challenge=None)— Authobject to use with LOGIN authentication. Requires self.user and self.password to be set.SMTP_SSL.auth_plain(self, challenge=None)— Authobject to use with PLAIN authentication. Requires self.user and self.password to be set.SMTP_SSL.close(self)— Close the connection to the SMTP server.SMTP_SSL.connect(self, host='localhost', port=0, source_address=None)— Connect to a host on a given port.SMTP_SSL.data(self, msg)— SMTP 'DATA' command -- sends message data to server.SMTP_SSL.docmd(self, cmd, args='')— Send a command, and return its response code.SMTP_SSL.ehlo(self, name='')— SMTP 'ehlo' command.SMTP_SSL.ehlo_or_helo_if_needed(self)— Call self.ehlo() and/or self.helo() if needed.SMTP_SSL.expn(self, address)— SMTP 'expn' command -- expands a mailing list.SMTP_SSL.getreply(self)— Get a reply from the server.SMTP_SSL.has_extn(self, opt)— Does the server support a given SMTP service extension?SMTP_SSL.helo(self, name='')— SMTP 'helo' command.SMTP_SSL.help(self, args='')— SMTP 'help' command.SMTP_SSL.login(self, user, password, *, initial_response_ok=True)— Log in on an SMTP server that requires authentication.SMTP_SSL.mail(self, sender, options=())— SMTP 'mail' command -- begins mail xfer session.SMTP_SSL.noop(self)— SMTP 'noop' command -- doesn't do anything :>SMTP_SSL.putcmd(self, cmd, args='')— Send a command to the server.SMTP_SSL.quit(self)— Terminate the SMTP session.SMTP_SSL.rcpt(self, recip, options=())— SMTP 'rcpt' command -- indicates 1 recipient for this mail.SMTP_SSL.rset(self)— SMTP 'rset' command -- resets session.SMTP_SSL.send(self, s)— Send 's' to the server.SMTP_SSL.send_message(self, msg, from_addr=None, to_addrs=None, mail_options=(), rcpt_options=())— Converts message to a bytestring and passes it to sendmail.SMTP_SSL.sendmail(self, from_addr, to_addrs, msg, mail_options=(), rcpt_options=())— This command performs an entire mail transaction.SMTP_SSL.set_debuglevel(self, debuglevel)— Set the debug output level.SMTP_SSL.starttls(self, *, context=None)— Puts the connection to the SMTP server into TLS mode.SMTP_SSL.verify(self, address)— SMTP 'verify' command -- checks for address validity.SMTP_SSL.vrfy(self, address)— SMTP 'verify' command -- checks for address validity.
Usage
import smtplib
# Implicit TLS SMTP client (port 465): with smtplib.SMTP_SSL(host, 465, timeout=30) as s: ...
assert issubclass(smtplib.SMTP_SSL, smtplib.SMTP)
Gotchas
- Pass
context=ssl.create_default_context()and uses.send_message(email_msg).
REPL Inspect
from smtplib import SMTP_SSL
help(SMTP_SSL)
Linked from
- tuts/python3/stdlib_module/smtplib
- tuts/python3/stdlib_module/smtplib/quoteaddr
- tuts/python3/stdlib_module/smtplib/quotedata
- tuts/python3/stdlib_module/smtplib/SMTP
- tuts/python3/stdlib_module/smtplib/SMTPAuthenticationError
- tuts/python3/stdlib_module/smtplib/SMTPConnectError
- tuts/python3/stdlib_module/smtplib/SMTPDataError
- tuts/python3/stdlib_module/smtplib/SMTPException
- tuts/python3/stdlib_module/smtplib/SMTPHeloError
- tuts/python3/stdlib_module/smtplib/SMTPNotSupportedError
- tuts/python3/stdlib_module/smtplib/SMTPRecipientsRefused
- tuts/python3/stdlib_module/smtplib/SMTPResponseException
- tuts/python3/stdlib_module/smtplib/SMTPSenderRefused
- tuts/python3/stdlib_module/smtplib/SMTPServerDisconnected
Related notes
- tuts/python3/stdlib_module/smtplib/quoteaddr Linked here; links to this page; shared tags: #smtplib, #stdlib
- tuts/python3/stdlib_module/smtplib/quotedata Linked here; links to this page; shared tags: #smtplib, #stdlib
- tuts/python3/stdlib_module/smtplib/SMTP Linked here; links to this page; shared tags: #smtplib, #stdlib
- tuts/python3/stdlib_module/smtplib/SMTPAuthenticationError Linked here; links to this page; shared tags: #smtplib, #stdlib
- tuts/python3/stdlib_module/smtplib Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/smtplib/SMTPConnectError links to this page; shared tags: #smtplib, #stdlib
- tuts/python3/stdlib_module/smtplib/SMTPDataError links to this page; shared tags: #smtplib, #stdlib
- tuts/python3/stdlib_module/smtplib/SMTPException links to this page; shared tags: #smtplib, #stdlib
- tuts/python3/stdlib_module/smtplib/SMTPHeloError links to this page; shared tags: #smtplib, #stdlib
- tuts/python3/stdlib_module/smtplib/SMTPNotSupportedError links to this page; shared tags: #smtplib, #stdlib