Skip to main content

Set of python scripts to create our mail alias tables from alias definitions

Project description

mail_alias_creator

A python program to create our mail alias tables from alias definitions

Configuration

A configuration file is needed to configure this software. By default it looks for mac.conf in the current working directory, but this can be changed by the -c command line option or the MAC_CONFIG environment variable.

The configuration file is read by python configparser and must adhere to its format.

A typical configuration file looks like this:

[main]
logging_conf = logging.conf
strict = false
check_syntax_only = false
dummy_sender_uid = mydummy
dummy_recipient_address = mydummy@example.com

[LDAP]
uri = ldaps://myldap.com
user_search_base = ou=users,dc=example,dc=com
group_search_base = ou=groups,dc=example,dc=com
user_filter = (objectClass=posixUser)
group_filter = (objectClass=posixGroup)
user_uid_field = uid
user_primary_mail_field = mail
group_id_field = cn
group_membership_field = memberUid

The logging_conf is file path relative to the main configuration file (or absolute). At this path should be a python logging.conf compatible logging configuration. This option may be omitted.

The strict flag enables strict checking of the inputs. In this case the program exits with a non-zero exit code when a possible problem with the given files is detected. This option may be omitted, which set's it to false.

The check_syntax_only flag can be used to abort the program after loading the alias files. This option may be omitted, which set's it to false.

The dummy_sender_uid and dummy_recipient_address fields are optional. It is also possible to set one and omit the other If set to a non-empty string the respective uid or address is used for all aliases that are defined but do not have an actual sender or recipient (this can be the case if the primary mail of a user can't be found, a group is empty, the forbidSend or forbidReceive flags are used or for the sender of an alias which only has entries of the external_address kind). This can be used to make sure the alias still appears in the generated lists giving the mail processing system the ability to react accordingly.

In the LDAP section some more variables than shown are supported. For a complete list and some explanations see ldap.py.

Alias defintion format

All given files and all files (recursively) in given folders are parsed as yaml files.

Each file must be of the following format:

meta:
  name: <name of the file>
  description: <description of the file>
aliases:
  <alias_mail>:
    description: <description of the alias>
    entries:
      - kind: <kind>
        ...
      - kind: <kind2>
        ...
  <alias_mail2> ...
  ...

Alias entry kind

The following kinds of alias entries are currently supported.

User

The user alias kind can be used to allow users to send and receive emails to/from this alias.

Kind name: user

Format:

- kind: user
  user: <username>
Optional attribues

The following optional attributes may be added.

name default description
forbidSend False Forbid the user to send via this alias.
forbidReceive False Don't foward incoming mails to that user.

Group

The group alias kind can be used to allow a whole group to send and receive emails to/from this alias.

Kind name: group

Format:

- kind: group
  group: <groupname>
Optional attribues

The following optional attributes may be added.

name default description
forbidSend False Forbid the group to send via this alias.
forbidReceive False Don't foward incoming mails to the users of this group.

Include alias

The include alias kind can be used to include another alias in this alias. As the argument another alias defined in this repo must be given. Every recipient from that given alias is also forwared incoming mails to this alias. Every sender from that given alias send mails via this alias. If the given address is not an alias defined in this repo there will be an error.

Kind name: include_alias

Format:

- kind: include_alias
  alias: <alias address>
Optional attribues

The following optional attributes may be added.

name default description
forbidSend False Forbid the members of the given alias to send via this alias.
forbidReceive False Don't foward incoming mails to the members of the given alias.

External address

The external address kind can be used to forward mails to external email addresses. Sending is not possible for entries with this kind.

Kind name: external_address

Format:

- kind: external_address
  address: <email address>
Optional attribues

Even though they do not make much sense, the following optional attributes may be added.

name default description
forbidSend False Forbid the members of the given alias to send via this alias.
forbidReceive False Don't foward incoming mails to the members of the given alias.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mail_alias_creator-1.2.0.tar.gz (11.2 kB view hashes)

Uploaded source

Built Distribution

mail_alias_creator-1.2.0-py3-none-any.whl (14.4 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page