Go to the latest version of this document.

# ``twisted`.`mail`.`mail`.`MailService``

class documentation

`class MailService(service.MultiService): (source)`

Constructor: `MailService()`

Implements interfaces: `twisted.cred.portal.IRealm`

View In Hierarchy

An email service.

Method | `__init__` | Initialize the mail service.
Method | `addDomain` | Add a domain for which the service will accept email.
Method | `defaultPortal` | Return the portal for the default domain.
Method | `getESMTPFactory` | Create an ESMTP protocol factory.
Method | `getPOP3Factory` | Create a POP3 protocol factory.
Method | `getSMTPFactory` | Create an SMTP protocol factory.
Method | `lookupPortal` | Find the portal for a domain.
Method | `requestAvatar` | Return a message delivery for an authenticated SMTP user.
Method | `setQueue` | Set the queue for outgoing emails.
Instance Variable | `aliases` | A mapping of domain name to alias.
Instance Variable | `domains` | A mapping of supported domain name to domain object.
Instance Variable | `monitor` | A service to monitor changes to files.
Instance Variable | `portals` | A mapping of domain name to authentication portal.
Instance Variable | `queue` | A queue for outgoing messages.
Instance Variable | `smtpPortal` | A portal for authentication for the SMTP server.

Inherited from `MultiService`:

Method | `__iter__` | Get an iterator over all child services.
Method | `addService` | Add a child service.
Method | `getServiceNamed` | Get the child service with a given name.
Method | `privilegedStartService` | Do preparation work for starting the service.
Method | `removeService` | Remove a child service.
Method | `startService` | Start the service.
Method | `stopService` | Stop the service.
Instance Variable | `namedServices` | Undocumented
Instance Variable | `parent` | An `IServiceCollection` which is the parent or `None`.
Instance Variable | `services` | Undocumented

Inherited from `Service` (via `MultiService`):

Method | `__getstate__` | Undocumented
Method | `disownServiceParent` | Use this API to remove an `IService` from an `IServiceCollection`.
Method | `setName` | Set the name of the service.
Method | `setServiceParent` | Set the parent of the service. This method is responsible for setting the `parent` attribute on this service (the child service).
Instance Variable | `name` | A `str` which is the name of the service or `None`.
Instance Variable | `running` | A `boolean` which indicates whether the service is running.

def __init__(self): (source)
overrides `twisted.application.service.MultiService.__init__`

Initialize the mail service.

def addDomain(self, name: `bytes`, domain: `IDomain`): (source)

Add a domain for which the service will accept email.

Parameters
name:`bytes` | A domain name.
domain:`IDomain` | A domain object.

def defaultPortal(self): (source)

Return the portal for the default domain.

The default domain is named ''.

Returns
`Portal` | The portal for the default domain.

def getESMTPFactory(self): (source)

Create an ESMTP protocol factory.

Returns
`ESMTPFactory` | An ESMTP protocol factory.

def getPOP3Factory(self): (source)

Create a POP3 protocol factory.

Returns
`POP3Factory` | A POP3 protocol factory.

def getSMTPFactory(self): (source)

Create an SMTP protocol factory.

Returns
`SMTPFactory` | An SMTP protocol factory.

def lookupPortal(self, name): (source)

Find the portal for a domain.

Parameters
name:`bytes` | A domain name.

Returns
`Portal` | A portal.

def requestAvatar(self, avatarId, mind, *interfaces): (source)
from `twisted.cred.portal.IRealm`

Return a message delivery for an authenticated SMTP user.

Parameters
avatarId:`bytes` | A string which identifies an authenticated user.
mind:`None` | Unused.
*interfaces:n-`tuple` of `zope.interface.Interface` | A group of interfaces one of which the avatar must support.

Returns
3-`tuple` of (1) `IMessageDelivery`, (2) `ESMTPDomainDelivery`, (3) no-argument callable | A tuple of the supported interface, a message delivery, and a logout function.

Raises
`NotImplementedError` | When the given interfaces do not include `IMessageDelivery`.

def setQueue(self, queue): (source)

Set the queue for outgoing emails.

Parameters
queue:`Queue` | A queue for outgoing messages.

aliases: `dict[bytes, IAlias] | None` = (source)

A mapping of domain name to alias.

domains: `dict` of `bytes` -> `IDomain` provider = (source)

A mapping of supported domain name to domain object.

monitor: `FileMonitoringService` = (source)

A service to monitor changes to files.

portals: `dict` of `bytes` -> `Portal` = (source)

A mapping of domain name to authentication portal.

queue: `Queue` or `None` = (source)

A queue for outgoing messages.

smtpPortal: `Portal` = (source)

A portal for authentication for the SMTP server.