authenticator Module

This module contains classes working together with the Smtp class to achieve authentication of the client. A base class BaseAuthenticator holds a reference to the session. Upon receiving a AUTH command, smtp.Smtp creates an authenticator based on the AUTH command’s parameters. The command line, split into words, is given to the start() method. If the authentication is concluded, it will return True. Otherwise more lines are fed with handleLine(). This also will return True when no more lines are required. Either start() or handleLine() are supposed to call pymail.smtp.Smtp.authenticate() to communicate the username and password to the object.

class pymail.authenticator.BaseAuthenticator(session)

Bases: object

Base class for authenticators

__init__(session)

Create authenticator

Parameters:session (Smtp) –
handleLine(_line)

Get a line from session

Parameters:line (string) –
Returns:True if no more lines are required
start(_words)

Start authentication

Parameters:words (string-list) – parameters from AUTH command
Returns:True if no more lines are required
class pymail.authenticator.PlainAuthenticator(session)

Bases: pymail.authenticator.BaseAuthenticator

Handler for PLAIN authentication

At the moment, only single line authentication is supported (thus no handleLine() method).

__init__(session)

Create PlainAuthenticator object

Parameters:session (Smtp) – Smtp session object
start(words)

Start authentication

Parameters:words (string-list) – command and parameters
Returns:True (since no more lines are involved)

The first parameter must be AUTH. The second parameter must be the username and password encoded according to RFC 4954 and RFC 4616.