email

Convenience wrappers for working with the ACCRE email server, as well as simple access to email mustache templates stored in a configured directory.

Templates should be in mustache format in a standard configurable directory. All such templates must end in “.mustache” and they will be collectively loaded on demand into a dictionary keyed by filename with the “.mustache” extension removed.

exception accre.email.ZimbraCommandError[source]

Bases: ACCREError

An error occurred running a zimbra command

accre.email.add_dl_addresses(dl, addresses, user='zimbra', timeout=60)[source]

Add a set of email addresses from the specified zimbra distribution list from the configured email server (internal interface). This requires ssh access to the email server as the specified user.

This is done using multiple commands in groups of 10 if many emails are specified.

Parameters:
  • dl (str) – Name of the specified zimbra distribution list

  • addresses (list(str)) – list of email addresses to add

  • user (str) – Name of the zimbra administrative user

  • timeout (int) – Timeout for executing remote zimbra command

accre.email.get_dl_addresses(dl, user='zimbra', timeout=60)[source]

Return a set of all email addresses currently in the specified zimbra distribution list from the configured email server (internal interface). This requires ssh access to the email server as the specified user.

Parameters:
  • dl (str) – Name of the specified zimbra distribution list

  • user (str) – Name of the zimbra administrative user

  • timeout (int) – Timeout for executing remote zimbra command

Returns:

Set of lowercased email addresses in the distribution list

Return type:

set(str)

accre.email.get_templates(reload=False)[source]

Return a dictionary of standard email templates, keyed by template name with the mustache contents as the value.

Parameters:

reload (bool) – If true, reread the templates directory even if it has already been read.

accre.email.remove_dl_addresses(dl, addresses, user='zimbra', timeout=60)[source]

Remove a set of email addresses from the specified zimbra distribution list from the configured email server (internal interface). This requires ssh access to the email server as the specified user.

This is done using multiple commands in groups of 10 if many emails are specified.

Parameters:
  • dl (str) – Name of the specified zimbra distribution list

  • addresses (list(str)) – list of email addresses to remove

  • user (str) – Name of the zimbra administrative user

  • timeout (int) – Timeout for executing remote zimbra command

accre.email.send_accre_email(body, *, recipients, sender='staff@accre.vanderbilt.edu', subject='Automated ACCRE message', reply_to=None, cc=None, bcc=None)[source]

Send an email using the ACCRE server to the designated recipients with a MIMEType of text.

Parameters:
  • body (str) – Body of the message (plain text)

  • recipients (list(str)) – List of valid email addresses to send the message to

  • sender (str) – The email address to be sent from

  • subject (str) – Subject line for the email

  • reply_to (str) – Reply-to email address, not set by default

  • cc (str) – cc email address, not set by default

  • bcc (str) – bcc email address, not set by default