Well... I got all this test cases right!
Theory of operation (for each maillogconvert output line):
if Amavis DISABLED
- Count every line
- Add mail_size * n_forwarders to mail_size of FORWARDED ONLY accounts.
if Amavis ENABLED
- Ignore non-local-address to non-local-address
- Drop the virtual transport lines
- Add mail_size / n_forwarders to mail_size of FORWARDED ONLY accounts.
The "Add mail_size.." step must be there because accounts that are forwarded only miss the local delivery line (input traffic count). mail_size / n_forwarders is the extra size that must be added to each outgoing delivery of this "forwarded only" accounts.
Test case 4: redir@dmn.tld -> me@external.dmn (forwarded only)
Code:
2008-06-19 08:21:26 me@external.dmn redir@dmn.tld test.server.tld mx.external.dmn SMTP - 1 778305
We have just one (outgoing delivery) line, so the extra size to this delivery line is:
Code:
extra_size = mail_size / n_forwarders = 778305 / 1 = 778305
Total count: 778305 + 778305 = 1556610
Test case 10: multiple@dmn.tld -> me@external.dmn, other@external.dmn (forwarded only)
Code:
2008-06-19 08:19:02 me@external.dmn multiple@dmn.tld test.server.tld 127.0.0.1 SMTP - 1 778323
2008-06-19 08:19:02 me@external.dmn multiple@dmn.tld test.server.tld 127.0.0.1 SMTP - 1 778323
We have two (outgoing delivery) lines, so the extra size to this delivery line is:
Code:
extra_size = mail_size / n_forwarders = 778305 / 2 = 389152.5
Total count: 2 lines * (778305 + 389152.5) bytes/line = 2334915
Warning: Do not use it on production yet please, we are missing test cases where a local user sends mails (both to other local users and external addresses).