4.4. User Settings

Alot sets up a SettingsManager to access user settings defined in different places uniformly. There are four types of user settings:

what? location accessible via
alot config ~/.config/alot/config or given by command option -c. SettingsManager.get()
hooks – user provided python code ~/.config/alot/hooks.py or as given by the hooksfile config value SettingsManager.get_hook()
notmuch config ~/.notmuch-config or given by $NOTMUCH_CONFIG or given by command option -n SettingsManager.get_notmuch_setting()
mailcap – defines shellcommands to handle mime types ~/.mailcap (/etc/mailcap) SettingsManager.mailcap_find_match()

4.4.1. Settings Manager

4.4.2. Errors

exception alot.settings.errors.ConfigError

could not parse user config

exception alot.settings.errors.NoMatchingAccount

No account matching requirements found.

4.4.3. Utils

alot.settings.utils.read_config(configpath=None, specpath=None, checks=None, report_extra=False)

get a (validated) config object for given config file path.

  • configpath (str or list(str)) – path to config-file or a list of lines as its content
  • specpath (str) – path to spec-file
  • checks (dict str->callable,) – custom checks to use for validator. see validate docs
  • report_extra (boolean) – log if a setting is not present in the spec file


Return type:


alot.settings.utils.resolve_att(a, fallback)

replace ‘’ and ‘default’ by fallback values

4.4.4. Themes

4.4.5. Accounts

class alot.account.Address(user, domain, case_sensitive=False)

A class that represents an email address.

This class implements a number of RFC requirements (as explained in detail below) specifically in the comparison of email addresses to each other.

This class abstracts the requirements of RFC 5321 § 2.4 on the user name portion of the email:

local-part of a mailbox MUST BE treated as case sensitive. Therefore, SMTP implementations MUST take care to preserve the case of mailbox local-parts. In particular, for some hosts, the user “smith” is different from the user “Smith”. However, exploiting the case sensitivity of mailbox local-parts impedes interoperability and is discouraged. Mailbox domains follow normal DNS rules and are hence not case sensitive.

This is complicated by § 2.3.11 of the same RFC:

The standard mailbox naming convention is defined to be “local-part@domain”; contemporary usage permits a much broader set of applications than simple “user names”. Consequently, and due to a long history of problems when intermediate hosts have attempted to optimize transport by modifying them, the local-part MUST be interpreted and assigned semantics only by the host specified in the domain part of the address.

And also the restrictions that RFC 1035 § 3.1 places on the domain name:

Name servers and resolvers must compare [domains] in a case-insensitive manner

Because of RFC 6531 § 3.2, we take special care to ensure that unicode names will work correctly:

An SMTP server that announces the SMTPUTF8 extension MUST be prepared to accept a UTF-8 string [RFC3629] in any position in which RFC 5321 specifies that a <mailbox> can appear. Although the characters in the <local-part> are permitted to contain non-ASCII characters, the actual parsing of the <local-part> and the delimiters used are unchanged from the base email specification [RFC5321]

What this means is that the username can be either case-insensitive or not, but only the receiving SMTP server can know what it’s own rules are. The consensus is that the vast majority (all?) of the SMTP servers in modern usage treat user names as case-insensitve. Therefore we also, by default, treat the user name as case insenstive.

  • user (str) – The “user name” portion of the address.
  • domain (str) – The domain name portion of the address.
  • case_sensitive (bool) – If False (the default) the user name portion of the address will be compared to the other user name portion without regard to case. If True then it will.
classmethod from_string(address, case_sensitive=False)

Alternate constructor for building from a string.

  • address (str) – An email address in <user>@<domain> form
  • case_sensitive (bool) – passed directly to the constructor argument of the same name.

An account from the given arguments

Return type:


class alot.account.Account(address=None, aliases=None, alias_regexp=None, realname=None, gpg_key=None, signature=None, signature_filename=None, signature_as_attachment=False, sent_box=None, sent_tags=None, draft_box=None, draft_tags=None, replied_tags=None, passed_tags=None, abook=None, sign_by_default=False, encrypt_by_default=u'none', encrypt_to_self=None, case_sensitive_username=False, **_)

Datastructure that represents an email account. It manages this account’s settings, can send and store mails to maildirs (drafts/send).


This is an abstract class that leaves send_mail() unspecified. See SendmailAccount for a subclass that uses a sendmail command to send out mails.


return all email addresses connected to this account, in order of their importance


sends given mail

Parameters:mail (email.message.Message or string) – the mail to send
Returns:a Deferred that errs back with a class:SendingMailFailed, containing a reason string if an error occurred.

stores mail (email.message.Message or str) as draft if draft_box is set.

static store_mail(mbx, mail)

stores given mail in mailbox. If mailbox is maildir, set the S-flag and return path to newly added mail. Oherwise this will return None.


absolute path of mail-file for Maildir or None if mail was successfully stored

Return type:

str or None




stores mail (email.message.Message or str) in send-store if sent_box is set.

abook = None

addressbook (addressbook.AddressBook) managing this accounts contacts

address = None

this accounts main email address

alias_regexp = []

regex matching alternative addresses

aliases = []

list of alternative addresses

encrypt_to_self = None

encrypt outgoing encrypted emails to this account’s private key

gpg_key = None

gpg fingerprint for this account’s private key

realname = None

real name used to format from-headers

signature = None

signature to append to outgoing mails

signature_as_attachment = None

attach signature file instead of appending its content to body text

signature_filename = None

filename of signature file in attachment

class alot.account.SendmailAccount(cmd, **kwargs)

Account that pipes a message to a sendmail shell command for sending

Parameters:cmd (str) – sendmail command to use for this account

Pipe the given mail to the configured sendmail command. Display a short message on success or a notification on error. :param mail: the mail to send out :type mail: email.message.Message or string :returns: the deferred that calls the sendmail command :rtype: twisted.internet.defer.Deferred

4.4.6. Addressbooks

class alot.addressbook.AddressBook(ignorecase=True)

can look up email addresses and realnames for contacts.


This is an abstract class that leaves get_contacts() unspecified. See AbookAddressBook and ExternalAddressbook for implementations.


list all contacts tuples in this abook as (name, email) tuples


looks up all contacts where name or address match query

class alot.addressbook.abook.AbookAddressBook(path='~/.abook/addressbook', **kwargs)

AddressBook that parses abook’s config/database files

Parameters:path (str) – path to abook addressbook file

list all contacts tuples in this abook as (name, email) tuples

class alot.addressbook.external.ExternalAddressbook(commandline, regex, reflags=0, external_filtering=True, **kwargs)

AddressBook that parses a shell command’s output

  • commandline (str) – commandline
  • regex (str) – regular expression used to match contacts in commands output to stdout. Must define subparts named “email” and “name”.
  • reflags (str) – flags to use with regular expression. Use the constants defined in re here (re.IGNORECASE etc.)
  • external_filtering (bool) – if True the command is fired with the given search string as parameter and the result is not filtered further. If set to False, the command is fired without additional parameters and the result list is filtered according to the search string.