Email Hooks

autoresponder_delete_pre.sh

This script is called before an autoresponder is deleted.

Environment variables

  • username: Directadmin username/owner of domain
  • domain: domain from which the autoresponder is deleted
  • user: name of autoresponder account

autoresponder_set_(pre|post).sh

This hook is for autoresponder creation and modification.

Environment variables

  • username : DA username
  • domain : domain for which the autoresponder is created
  • user : name of the autoresponder
  • cc (1|0): whether the cc checkbox is set
  • email : cc value set
  • header (1|0): relating to the html/utf-8 autoreplies
  • reply_encoding: encoding used in response
  • reply_content_type: content type of the response (e.g., text/plain)
  • subject: prefix used in the response subject
  • reply_once_time: Minimum time before a repeated reply

email_change_pass_(pre|post).sh

This script is called before/after an email user's password is changed.

Environment variables

  • user : email account user
  • domain : domain where the user is located
  • passwd : new user password... this value is encrypted when password change is coming from a peer via the Multi-Server configuration
  • passwd_is_crypted : if set to 1, passwd is encrypted.
  • quota : email account quota
  • user_can_set_email_limit : directadmin.conf value:user_can_set_email_limit

email_create_(pre|post).sh

This hook is called before/after the virtual email is created.

Environment variables

  • Username: directadmin account
  • user: email account name
  • domain: domain where virtual email is created
  • passwd: password of account
  • passwd_is_crypted(0|1): if set, passwd is encrypted
  • quota: disk quota in Mib for email account (0 is unlimited)
  • limit: daily send limit (0 is unlimited)

email_destroy_(pre|post).sh

This hook script is ran before/after an email account is removed.

Environment variables

  • username: DA user name
  • domain: domain where deleted email account is located
  • user: email account to be deleted

email_filter_write_(pre|post).sh

This hook is called before/after the filter file at /etc/virtual/domain.com/filter is modified.

Environment variables

  • username : owner of domain
  • domain : domain for which the filter is modified
  • adult : set to ON if the adult filter is turned on
  • /etc/virtual/domain.ltd/filter.conf contents for each entry:
    • environment variable key: a number id of the rule
    • type: type of the rule... possible values include the following:
      • domain: domain from which all email would be blocked
      • email: specific email to filter out
      • word: block email if string defined by value is found
      • size: email size limit
    • value: the value for the type
    • example: type=size&value=100
  • The tokens for "filter"... the most useful include the following:
    • DOVECOT (yes|no): is dovecot is used on the server
    • HOME: user's home directory
    • INBOX_SPAM (drop|INBOX.spam): drop spam or save it into INBOX.spam folder
    • MAIL_PARTITION_HOME: folder where users imap folder could be found

forwarder_(create|delete)_(pre|post).sh

These custom scripts are used for creating, setting, and deleting forwarders.

Note that this will also be called when the catch-all is set.

Environment variables

username: DA account name file: domain aliases file (/etc/virtual/domain.com/aliases) user: forwarder name value: (forwarder_create_(pre|post).sh only) address to forward to domain: domain for which forwarder is created


vacation_set_(pre|post).sh

Hook scripts used when the User sets a vacation message (creation or alteration).

Environment variables

  • username: Directadmin username/owner of domain
  • domain: user domain
  • user: email user for which vacation is set
  • text: vacation message
  • return_code(0|1):(post script only) if set to 0, an error occurred during vacation set, but if set to 1, no error resulted
  • start time variables:
    • startyear
    • startmonth
    • startday
    • starttime
  • end time variables:
    • endyear
    • endmonth
    • endday
    • endtime

mailing_list_save_post.sh

Hook script used after a mailing list is modified

Create directory

mkdir -p /usr/local/directadmin/scripts/custom/mailing_list_save_post

And place your hook script in that directory. It can be named anything. For example: /usr/local/directadmin/scripts/custom/mailing_list_save_post/myhook.sh

Environment variables

The environment values passed will be the same as the tokens that are set in the template: /usr/local/directadmin/data/templates/list.config

These tokens correspond to the similarly named option fields in DirectAdmin's mailing list page. Note that all of these options are specific to majordomo. If any descriptions are missing then further documentation should be looked for in documentation related to majordomo specifically.

Most of the descriptions found here were gathered from the following sources: utas.edu.auopen in new windowsilo.tipsopen in new window

  • Mailing list info:
    • name: name of the mailing list.
    • NAME: the name of the mailing list's email digest. A Majordomo digest is actually a separate mailing list. The digest of name would normally be called name-digest.
    • digest_name: name of the mailing list.
    • admin_passwd: anyone can administrate majordomo from any email account as long as that individual uses this password.
    • approve_passwd: this password is used to approve postings to a restricted or moderated list.
    • domain: the domain the mailing list belongs to.
    • info: "list information" input box's details.
    • description: your list's description. It will appear when a user uses a command to request a list of lists.
    • sender: this address is what gets copied into the message body as the "From" or "Return-Path" header.
  • Message info:
    • message_headers
    • message_footer: the text you want to appear at the end of every message.
    • taboo_body:
    • message_fronter: the text you want to appear at the beginning of every message.
    • subject_prefix: the word supplied here will be added to the beginning of the subject line of every message sent to your list.
  • Digest settings. A digest version of a list is a way to reduce the number of messages sent from Majordomo to subscribers. Normally, each message to the list is remailed to all the subscribers, but with a digest, several messages are collected into a batch and then sent together as one message.
    • digest_maxdays: Majordomo will send a digest automatically when the number of days since last the last digest exceeds maximum amound of days.
    • digest_maxlines:
    • digest_work_dir:
    • digest_volume:
    • digest_archive:
    • digest_issue:
    • digest_rm_fronter:
    • digest_rm_footer:
  • taboo_headers:
  • reply_to: the email address that should be contacted by the recipients of this mailing list.
  • comments:
  • intro_access:
    • open - anyone can retrieve the introduction file associated with your list,
    • closed - no one can retrieve the introduction file,
    • list - only list members can retrieve the introduction file associated with your list.
  • LANGUAGE:
  • noadvertise:
  • welcome:
  • moderate:
    • yes - all postings must be approved,
    • no - anyone can post a message to the list.
  • precedence:
  • json:
  • mungedomain:
  • date_intro:
  • debug:
  • who_access:
    • open - only list members can retrieve the list membership.
    • closed - anyone can retrieve the list of list members.
    • list - no one can retrieve the list of list members.
  • restrict_post: set this option to the name of your list to restrict posting to list members only. Any attempts to post to the list by non-members will be 'bounced' to you for your approval.
  • administrivia:
    • yes - any subscribe or unsubscribe requests sent to name@domain instead of to majordomo@domain will be bounced to the list owner for approval. Here name and domain are previously mentioned values.
    • no - subscribe and unsubscribe requests will not be filtered out but will be posted to all list members.
  • advertise:
  • INVOCATION_ID:
  • action:
  • strip:
  • date_info:
  • resend_host:
  • archive_dir:
  • announcements:
  • get_access:
  • moderator:
  • purge_received:
  • which_access:
    • open - anyone can check whether any e-mail address is on the list.
    • closed - no one can check whether an address is on the list.
    • list - only list members can check whether an address is on the list.
  • info_access:
    • open - anyone can retrieve the information file associated with your list.
    • closed - no one can retrieve the information file.
    • list - only list members can retrieve the information file associated with your list.
  • JOURNAL_STREAM:
  • subscribe_policy:
    • open - individuals may subscribe themselves to the list without the list administrator's approval, but requests to subscribe others are sent to the list approver for approval.
    • closed - all subscription requests require list owner approval.
    • auto - anyone can subscribe anyone else from the list.
  • unsubscribe_policy:
    • open - anyone can unsubscribe their own address.
    • closed - requests to unsubscribe are forwarded to the list owner for approval.
    • auto - anyone can unsubscribe anyone else from the list.
  • index_access:
  • login_key_name:
  • maxlength:

Email DNS Authentication

dkim_create_post.sh

New hook script, called after the dkim_create.sh has finished running, and was successful.

Use exit 0; for success, and exit with a non-zero for error.

The result will be added to the output regardless, but only shown if there is an error.

Environment variables

  • domain: domain for which DKIM is created

dnssec_sign_post.sh

This script is called after a zone is signed, but before any clustering sends it off to the slave DNS servers.

If all is well, and you want the clustering (if enabled) to proceed, use exit code 0.

If there is an error and you need it to abort the clustering push, then use any non-zero value so that the signing function call will abort after the local file is signed, but before the clustering push happens.

Environment variables

  • domain: domain zone that was signed
  • return_code (0|1): the success/failure of the actual signing... 1 is success, 0 means there was an error.
  • do_cluster (0|1):set to 1 if directadmin.conf cluster=1 AND it's a local trigger. Remote slaves get the raw copy anyway, so do_cluster=0 might only be seen if directadmin.conf cluster=0.
    The only remote case would be remote per-record changes, which has been seldom used, if ever.
    Possible use may be necessary in the future, so just be sure you handle it if you need to do different actions based on this value (e.g., dns-01 wildcard LetsEncrypt requests).

Spam

spamassassin_destroy_pre.sh (rspamd_destroy_pre.sh)

This script is called before spamassassin/rspamd is disabled for domain.

If rspamd is used, the hook script is aptly named rspamd_destroy_pre.sh.

Environment variables

  • username: owner of domain
  • domain: domain for which spamassassin/rspamd is disabled

spamassassin_edit_(pre|post).sh (rspamd_edit_(pre|post).sh)

This hook is run before/after a user modifies spamassasin (rspamd) settings.

If rspamd is used, the hook is aptly named rspamd_edit_(pre|post).sh.

Environment variables

  • where (inbox|delete|spamfolder|userspamfolder): where to send mail marked as spam... options are:
    • inbox : users inbox
    • delete : remove mail completely
    • spamfolder : catch-all spam folder
    • userspamfolder : account's spam folder
  • required_hits (5.0|7.5|10.0|custom): spam score threshold
  • required_hits_custom: whether required_hits is set to custom... custom spam score threshold
  • rewrite_subject (0|1): whether the subject should be rewritten:
    • 0 - leave subject unchanged.
    • 1 - add tags
  • subject_tag: custom tag to be added to the subject if rewrite_subject=1
  • report_safe (0|1|2): How should the spam be delivered
    • 0 - Don't use attachments (dangerous)
    • 1 - Use attachments
    • 2 - Use text-only attachments
  • blacklist_from: list of email addresses that will be blocked. One per line.
  • whitelist_from: list of email addresses that will be allowed through, regardless of content. One per line.

spam_script_chmod_0_post.sh

This hook is related to the directadmin.conf value:parse_php_mail_log_at_limit.

It is run after a spamming script mode bits are set to 0 with chmod 000.

Environment variables

  • script: absolute path to script
  • username: owner of script

Examples

Rename the spam script to flag it as such.

Add the following to spam_script_chmod_0_post.sh, chmod to 700, and then chown to diradmin:

#!/bin/sh
mv ${script} ${script}.${username}.spam
RET=$?
exit $RET
Last Updated: