Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`mail`.`relaymanager`.`MXCalculator``

class documentation

`class MXCalculator: (source)`

View In Hierarchy

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

Method | `__init__` | No summary
Method | `getMX` | Find the name of a host that acts as a mail exchange server for a domain.
Method | `markBad` | Record that a mail exchange host is not currently functioning.
Method | `markGood` | Record that a mail exchange host is functioning.
Instance Variable | `badMXs` | A mapping of non-functioning mail exchange hostname to time at which another attempt at contacting it may be made.
Instance Variable | `clock` | A reactor which will be used to schedule timeouts.
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`).
Instance Variable | `resolver` | A resolver.
Instance Variable | `timeOutBadMX` | Period in seconds between attempts to contact a non-functioning mail exchange host.
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.
Method | `_filterRecords` | Organize the records of a DNS response by record name.

def __init__(self, resolver=None, clock=None): (source)

Parameters
resolver:`IResolver` provider or `None` | A resolver.
clock:`IReactorTime` provider or `None` | A reactor which will be used to schedule timeouts.

def getMX(self, domain, maximumCanonicalChainLength=3): (source)

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

Parameters
domain:`bytes` | A domain name.
maximumCanonicalChainLength:`int` | The maximum number of unique canonical name records to follow while looking up the mail exchange host.
Returns
`Deferred` which successfully fires with `Record_MX` | A deferred which succeeds with the MX record for the mail exchange server for the domain or fails if none can be found.

def markBad(self, mx): (source)

Record that a mail exchange host is not currently functioning.

Parameters
mx:`bytes` | The hostname of a mail exchange host.

def markGood(self, mx): (source)

Record that a mail exchange host is functioning.

Parameters
mx:`bytes` | The hostname of a mail exchange host.

badMXs: `dict` mapping `bytes` to `float` = (source)

A mapping of non-functioning mail exchange hostname to time at which another attempt at contacting it may be made.

clock: `IReactorTime` provider = (source)

A reactor which will be used to schedule timeouts.

fallbackToDomain: `bool` = (source)

A flag indicating whether to attempt to use the hostname directly when no mail exchange can be found (`True`) or not (`False`).

resolver: `IResolver` = (source)

A resolver.

timeOutBadMX: `int` = (source)

Period in seconds between attempts to contact a non-functioning mail exchange host.

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.

Parameters
answers:`dict` mapping `bytes` to `list` of `IRecord` provider | A mapping of record name to record payload.
domain:`bytes` | A domain name.
cnamesLeft:`int` | The number of unique canonical name records left to follow while looking up the mail exchange host.
Returns
`Record_MX` or `Failure` | An MX record for the mail exchange host or a failure if one cannot be found.

def _ebMX(self, failure, domain): (source)

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

Parameters
failure:`Failure` | The reason for the lookup failure.
domain:`bytes` | The domain name.
Returns
`Record_MX` or `Failure` | An 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.
Raises
`IOError` | When no MX record could be found and the fallback to domain option is not in effect.
`DNSLookupError` | When no MX record could be found and the fallback to domain option is in effect but no address for the domain could be found.

def _filterRecords(self, records): (source)

Organize the records of a DNS response by record name.

Parameters
records:3-`tuple` of (0) `list` of `RRHeader`, (1) `list` of `RRHeader`, (2) `list` of `RRHeader` | Answer resource records, authority resource records and additional resource records.
Returns
`dict` mapping `bytes` to `list` of `IRecord` provider | A mapping of record name to record payload.