A utility for looking up mail exchange hosts and tracking whether they are working or not.

Instance Variable clock A reactor which will be used to schedule timeouts. (type: IReactorTime provider)
Instance Variable resolver A resolver. (type: IResolver)
Instance Variable badMXs A mapping of non-functioning mail exchange hostname to time at which another attempt at contacting it may be made. (type: dict mapping bytes to float)
Instance Variable timeOutBadMX Period in seconds between attempts to contact a non-functioning mail exchange host. (type: int)
Instance Variable fallbackToDomain A flag indicating whether to attempt to use the hostname directly when no mail exchange can be found (True) or not (False). (type: bool)
Method __init__
Method markBad Record that a mail exchange host is not currently functioning.
Method markGood Record that a mail exchange host is functioning.
Method getMX Find the name of a host that acts as a mail exchange server for a domain.
Method _filterRecords Organize the records of a DNS response by record name.
Method _cbMX Try to find the mail exchange host for a domain from the given DNS records.
Method _ebMX Attempt to use the name of the domain directly when mail exchange lookup fails.
clock =
A reactor which will be used to schedule timeouts. (type: IReactorTime provider)
resolver =
A resolver. (type: IResolver)
badMXs =
A mapping of non-functioning mail exchange hostname to time at which another attempt at contacting it may be made. (type: dict mapping bytes to float)
timeOutBadMX =
Period in seconds between attempts to contact a non-functioning mail exchange host. (type: int)
fallbackToDomain =
A flag indicating whether to attempt to use the hostname directly when no mail exchange can be found (True) or not (False). (type: bool)
def __init__(self, resolver=None, clock=None): (source)
ParametersA resolver.
clockA reactor which will be used to schedule timeouts. (type: IReactorTime provider or None)
def markBad(self, mx): (source)

Record that a mail exchange host is not currently functioning.

ParametersmxThe hostname of a mail exchange host. (type: bytes)
def markGood(self, mx): (source)

Record that a mail exchange host is functioning.

ParametersmxThe hostname of a mail exchange host. (type: bytes)
def getMX(self, domain, maximumCanonicalChainLength=3): (source)

Find the name of a host that acts as a mail exchange server for a domain.

ParametersdomainA domain name. (type: bytes)
maximumCanonicalChainLengthThe maximum number of unique canonical name records to follow while looking up the mail exchange host. (type: int)
ReturnsA deferred which succeeds with the MX record for the mail exchange server for the domain or fails if none can be found. (type: Deferred which successfully fires with Record_MX)
def _filterRecords(self, records): (source)

Organize the records of a DNS response by record name.

ParametersrecordsAnswer resource records, authority resource records and additional resource records. (type: 3-tuple of (0) list of RRHeader, (1) list of RRHeader, (2) list of RRHeader)
ReturnsA mapping of record name to record payload. (type: dict mapping bytes to list of IRecord provider)
def _cbMX(self, answers, domain, cnamesLeft): (source)

Try to find the mail exchange host for a domain from the given DNS records.

This will attempt to resolve canonical name record results. It can recognize loops and will give up on non-cyclic chains after a specified number of lookups.

ParametersanswersA mapping of record name to record payload. (type: dict mapping bytes to list of IRecord provider)
domainA domain name. (type: bytes)
cnamesLeftThe number of unique canonical name records left to follow while looking up the mail exchange host. (type: int)
ReturnsAn MX record for the mail exchange host or a failure if one cannot be found. (type: Record_MX or Failure)
def _ebMX(self, failure, domain): (source)

Attempt to use the name of the domain directly when mail exchange lookup fails.

ParametersfailureThe reason for the lookup failure. (type: Failure)
domainThe domain name. (type: bytes)
ReturnsAn MX record for the domain or a failure if the fallback to domain option is not in effect and an error, other than not finding an MX record, occurred during lookup. (type: Record_MX or Failure)
RaisesIOErrorWhen no MX record could be found and the fallback to domain option is not in effect.
DNSLookupErrorWhen no MX record could be found and the fallback to domain option is in effect but no address for the domain could be found.
API Documentation for Twisted, generated by pydoctor at 2016-10-29 16:19:29.