Logic Flow - 13 Nov 2004
- Connection: (arguments: hostname, IP address)
- If config file has changed, reload
- Accept any connection from 127.0.0.1
- Accept any connection from the Global IP Whitelist
- If greylisting, check against the greylist and TEMPFAIL if necessary
- Reject any connection from the Global IP Blacklist
- [optional] HELO/EHLO: (argument: hostname)
- Reject any IP address argument in the Global IP Whitelist (spoof prevention)
- MAIL: (argument: envelope sender)
- If using MX verification, attempt a connection to the MX or A record of the envelope sender domain.
- RCPT: (argument: envelope recipient)
- For each recipient:
- If Unknown Users threshold has been reached, add IP address to MAX_UNKNOWN_USERS_BL
- If duplicate recipient is specified, reject the duplicate
- Force recipient to lowercase
- If recipient is not a full email address, use Default Domain
- Check user@domain, for all subdomains of domain, for an alias (first) or valid filter settings (second)
- If neither an alias nor valid filter settings are found, use Default Domain for further processing
- If recipient is a spamtrap, reject recipient and add IP address to SPAMTRAP_BL
- If user verification is used, and user cannot be verified, increase Unknown Users count and reject with User Unknown
- If neither an alias nor valid filter settings were previously found, accept this recipient
- If an alias was found, rewrite username and domain
- Accept recipient if user's whitelist is matched
- Do not use domain logging if a domain logging exception is found
- If the domain has DOMAIN_LOGGING turned on, or global domain logging is turned on but the domain is not the Default Domain, use domain logging (use the domain name for the logfile and quarantine, not the full email address)
- If not using domain logging, set the logfile and quarantine directory to user's full email address
- If the SF_WHITELIST_ONLY filter is set to Reject, reject the recipient. If Tag or Quarantine, set the recipient's current status as Tag or Quarantine.
- Check each non-content filter in turn. If set to Reject, reject the recipient. If Tag or Quarantine, set the recipient's status if greater than the current status (ie, do not overwrite a Quarantine status with a Tag status).
- If user has a content filter selected (ie, SF_VIRUS, SF_SPAMASSASSIN, or SF_DSPAM), or the current status is Tag or Quarantine, open temporary quarantine file for user.
- BODY: Headers (arguments: header name, header value)
- For each recipient:
- Check From: header against user's whitelist and set whitelist status if found
- If whitelist status is not set, check From: header against user's blacklist if SF_PERSONAL_BLACKLIST is set, and update status as required
- If we're doing content filtering, and status is not yet Reject, and whitelist status is not set, and a quarantine file is open for user, write each header to temporary quarantine file. Modify the Subject: header if use_subject_tagging is set.
- BODY: End of Headers (arguments: [none])
- For each recipient:
- If we're doing content filtering or status is Tag or Quarantine, and whitelist status is not set, and a quarantine file is open for user, add an X-spasm: header for each filter that has caught the message, and add X-spasm-rcpt:, X-spasm-sender:, X-spasm-sender-IP:, X-spasm-sender-host:, and X-spasm-date: headers.
- BODY: Text (arguments: body text, text length)
- For each recipient:
- If we're doing content filtering or status is Tag or Quarantine, and whitelist status is not set, and a quarantine file is open for user, write body text to temporary quarantine file.
- Scan for executable attachments as necessary.
- BODY: End of Message (arguments: [none])
- For each recipient:
- If a quarantine file is open, close it.
- If the current status is Reject, from a header-level rejection, delete recipient from sendmail's list of recipients
- If the status is not yet Reject, and the whitelist status is not set, run each content filter as necessary. Upon a Reject result, delete recipient from sendmail's list of recipients. Update status as required.
- If the current status is Quarantine, delete recipient from sendmail's list of recipients and move temporary quarantine file to user's (or domain's) permanent quarantine directory
- If the current status is Tag, deliver the quarantine file to the recipient, delete quarantine file, and delete recipient from sendmail's list of recipients
- If the current status is Reject or the message wasn't caught by any filters, delete quarantine file
- If another message is to be sent in this connection, repeat at MAIL above.