1.1.6.2. gnr.utils.ssmtplib

Last page update: September 28, 2011

Main class:

Exceptions classes:

Complete reference:

1.1.6.2.2. SMTPSSLException

there is no public method.

1.1.6.2.3. gnr.sql.PersistentDB - The complete reference list

exception gnr.utils.ssmtplib.SMTPSSLException

Base class for exceptions resulting from SSL negotiation

class gnr.utils.ssmtplib.SMTP_SSL(host='', port=0, local_hostname=None, keyfile=None, certfile=None)

This class provides SSL access to an SMTP server.

SMTP over SSL typical listens on port 465. Unlike StartTLS, SMTP over SSL makes an SSL connection before doing a helo/ehlo. All transactions, then, are done over an encrypted channel.

This class is a simple subclass of the smtplib.SMTP class that comes with Python. It overrides the connect() method to use an SSL socket, and it overrides the starttls() function to throw an error (you can’t do starttls within an SSL session)

connect(host='localhost', port=0)

Connect to an SMTP server using SSL.

‘host’ is localhost by default. Port will be set to 465 (the default SSL SMTP port) if no port is specified.

If the host name ends with a colon (‘:’) followed by a number, that suffix will be stripped off and the number interpreted as the port number to use. This will override the ‘port’ parameter.

Note

this method is automatically invoked by __init__, if a host is specified during the instantiation

setcertfile(certfile)

Set the absolute path to a file containing a x.509 certificate.

This method will only be effective if it is called before connect()

This certificate will be used to make the SSL connection.

setkeyfile(keyfile)

Set the absolute path to a file containing a private key.

This method will only be effective if it is called before connect()

This key will be used to make the SSL connection.

starttls()

Raises an exception.

You cannot do StartTLS inside of an ssl session. Calling starttls() will return an SMTPSSLException