4.6 - The Reports Task

4.6.1 - Function

The Reports Task is a NAFlet which generates NDRs for bounced messages. NDRs (Non Delivery Reports) are special email messages which report the failure of another message, in a standardised format.

This task periodically polls the queue (see §4.3) for bounces, and processed a batch of them, analogously to how the Delivery task functions (see §4.5). It goes through the batch, generating an NDR for each bounce and injecting it into the queue, following which it removes the original bounced message.

Unlike the Submit and Delivery tasks, this task does not participate in any network connections.


4.6.2 - Task Config

<report>
    <audit rot="monthly">%DIRLOG%/audit/Y%Y%/bounced-%DT%.log</audit>
    <interval_low>5s</interval_low>
    <interval_high>1m</interval_high>
    <interval_error>3m</interval_error>
    <delay_start>20s</delay_start>
    <queuecache>100</queuecache>
    <generate_ndr>Y</generate_ndr>
    <ndr_recip_redirect>me_instead@mydomain.com</ndr_recip_redirect>
    <ndr_recips_additional>me_too@somedomain.com | and_me@anotherdomain.com</ndr_recips_additional>
    <ndr_copies_folder>%DIRVAR%/bounces</ndr_copies_folder>
    <announcemta>%SYSNAME%</announcemta>
    <ndr_from>postmaster@thisdomain</ndr_from>
    <ndr_subject>Delivery Failure Report</ndr_subject>
    <ndr_textpart></ndr_textpart>
    <attachmsg>4K</attachmsg>
</report>

audit
This specifies an audit log, reporting all message bounces.
It is meant to serve as a formal record of activity, suitable for archiving (as opposed to the more debug-oriented trace logs). It records the timestamp at which failure was declared, the bounced message's sender and recipient email addresses, the failure diagnostic, and the IP address the message was originally received from.
This config item supports the same attributes as the GreyLog loggers (rotation, buffering, etc - see GreyLog Guide).
This config item has no default and auditing will be turned off if it is omitted.

interval_low
If any entries were found when we polled the queue to build the latest cached batch, this is the pause before polling again.
Defaults to 5 seconds.

interval_high
If no entries were found when we polled the queue to build the latest cached batch, this is the pause before polling again.
Defaults to 1 minute.

interval_error
If we encountered an error when we polled the queue to build the latest cached batch, this is the pause before polling again.
Defaults to 3 minutes.

delay_start
This specifies the pause on initial system startup, before we first poll the queue.
Defaults to 1 minute.

queuecache
This specifies the max size of the bounces batch, measured as the number of cached queue entries (each queue entry constitutes a unique recipient/message combination).
This defaults to 100 and is also subject to the limit imposed by the queue manager itself, with its maxmemoryqueue setting (see §4.3.1).
This batch size should not be set too large, as the Reports Task will not be responsive to other events while it is processing it, and this would hinder its suggested role as the NAFMAN Primary agent.

generate_ndr
This controls whether we generate NDRs at all, or just discard bounced messages silently.
Defaults to Yes, ie. do generate NDRs.

ndr_recip_redirect
NDRs are normally sent to the original message's sender, but this setting lets you override that, and divert them to another email address.
This setting is blank by default, and the special value of . (dot) denotes the "Sink" recipient, which means don't send the NDR to anybody at all.
If you simply wanted to disable NDRs, you'd use the generate_NDR setting, so the concept of the Sink recipient setting is intended to support a scenario where you do want to generate NDRs, but just not in email form (see ndr_copies_folder) or only to an alternative set of recipients (see ndr_recips_additional).

ndr_recips_additional
This specifies an additional set of recipients to whom the NDR should be copied, in addition to the main recipient (or instead of, if ndr_recip_redirect is set to the Sink destination).
Note that the SMTP standard requires that an NDR only have one recipient, so the Reports task generates an additional message for each additional recipient, rather than one message to multiple recipients.

ndr_copies_folder
This specifies that a copy of each NDR should be saved as a file in the specified directory, in addition to (or instead of) being emailed to one or more recipients.
This setting could be used to support a scenario where you have another application running on the mailserver that wishes to process all NDRs, and it could poll this directory.
NDRs are not archived to file, by default.

announcemta
This specifies the hostname we will use in the NDR message ID, and wherever the NDR has to declare which MTA generated it.
Defaults to the announcehost setting in the application config block (see §4.1).

ndr_from
This specifies the email address we will insert into the NDR's From address.
By default, it's based on the announcehost setting in the application config block (see §4.1). We take the hostname configured there, strip the first portion if its a fully qualified domain name, and then prepend postmaster@.
This means that if for example the System announcehost was hostname.mydomain.com the default value for this setting would come out as postmaster@mydomain.com.
Note that this strictly refers to the RFC822 From address in the NDR's message headers. It is NOT the SMTP envelope sender - the SMTP standard decrees that should be blank, to prevent endless loops.

ndr_subject
This specifies the Subject heading we will use in the generated NDRs.
Defaults to Delivery Failure Report

ndr_textpart
An NDR is a MIME message consisting of multiple bodyparts, of which the first part is a plain text explanation of the problem.
This setting lets you specify the wording of this bodypart, and the default is as follows:

This is the %PRODNAME% mailserver at %REPMTA%.
Your message could not be delivered - the details are attached.

Where:
%PRODNAME% defaults to Mailismus%REPMTA% is replaced by the value of the announcemta setting above

attachmsg
An NDR is a MIME message consisting of multiple bodyparts, of which the final part is the attached original message (ie. the message which bounced).
This setting specifies how much of the bounced message to attach, and defaults to 4K. A value of zero means don't attach the bounced message at all.