4. VirtualMailManager.Alias — Handling of alias e-mail addresses

This module provides the Alias class. The data are read from/stored in the alias table. This table is used by Postfix to rewrite recipient addresses.

4.1. Alias

class VirtualMailManager.Alias.Alias(dbh, address)

Creates a new Alias instance. Alias instances provides the __len__() method. So the existence of an alias in the database can be tested with a simple if condition.

Parameters:
add_destinations(destinations, expansion_limit[, warnings=None])

Adds the destinations to the destinations of the alias. This method returns a set of all addresses which successfully were stored into the database.

If one of the e-mail addresses in destinations is the same as the alias address, it will be silently discarded. Destination addresses, that are already assigned to the alias, will be also ignored.

When the optional warnings list is given, all ignored addresses will be appended to it.

Parameters:
Return type:

set

Raises:

VirtualMailManager.errors.AliasError – if the additional destinations will exceed the expansion_limit or if the alias already exceeds its expansion_limit.

See also

VirtualMailManager.ext.postconf – to read actual values of Postfix configuration parameters.

del_destination(destination)

Deletes the given destination address from the alias.

Parameters:

destination (VirtualMailManager.EmailAddress.EmailAddress) – a destination address of the alias

Return type:

None

Raises:

VirtualMailManager.errors.AliasError – if the destination wasn’t assigned to the alias or the alias doesn’t exist.

delete()

Deletes the alias with all its destinations.

Return type:

None

Raises:

VirtualMailManager.errors.AliasError – if the alias doesn’t exist.

get_destinations()

Returns an iterator for all destinations (EmailAddress instances) of the alias.

Return type:

listiterator

Raises:

VirtualMailManager.errors.AliasError – if the alias doesn’t exist.