spooler Module

The Spooler class in this module takes care of processing e-mail in the spool database

pymail.spooler.DEFAULT_RETRY_PLAN = ['4*30m', '22*1h', '4*1d']

Default retry plan

pymail.spooler.DEFAULT_SPOOLFILE = '/var/spool/pymail'

Default spool file

pymail.spooler.ERROR_TEMPLATE = '\nDelivery to the following recipient failed permanently:\n\n%(destination)s\n\n%(message)s\n'

Spool SQL schema

class pymail.spooler.Spooler(router, config)

Bases: object

The spooler mechanism

CRONPAUSE = 10

Pause (seconds) to wait between periodical scans

__init__(router, config)

Create Spooler object

Parameters:config – server configuration
bounce(jobId, error, address, source, destination)

Bounce message and remove

Parameters:
  • jobId (string) –
  • error (string) – error message
  • address (string) – domain to use as source
  • destination (string) – destination e-mail address
config = None

Configuration

cron()

Periodically start scan

log = None

Logger

process(jobId)

Process job

Parameters:
  • jobId (int) –
  • messageId (string) –
  • mailSource (string) –
  • mailDestination (string) –
  • headers (string) – pickled dict
  • spooled (datetime.dateime) – time of spooling
  • tries (int) –
retryPlan = None

Retry plan

returnError(address, source, destination, message)

Return error mail back to source

Parameters:
  • address (string) –
  • source (string) –
  • destination (string) –
  • message – something that can be converted to a string
router = None

Router

scan()

Scan spool file/directory for mail to process

scanRunning = None

Flag: True when scan is running

sinks = {'shred': <class 'pymail.sink.Null'>, 'smtp': <class 'pymail.sink.Smtp'>, 'maildir': <class 'pymail.sink.MailDir'>, 'dump': <class 'pymail.sink.Dump'>}

Registry of mail sinks

spoolFile = None

Spool file

spoolPath = None

Spool directory (from configuration)

pymail.spooler.prepare(path, uid, gid)

Prepare spool file/directory

Parameters:
  • path (string) – path to spool file/directory (if None, a default is chosen)
  • uid (int) –
  • gid (int) –