ispconfig3+dovecot with mailbox traffic

Discussion in 'Tips/Tricks/Mods' started by djtremors, Oct 17, 2010.

  1. djtremors

    djtremors ISPConfig Developer ISPConfig Developer

    Hey all,

    I had an older courier ispc3 system and converted it to dovecot for one of many reasons but one problem I didn run into is that ispc3 no longer tracks the mailbox traffic information (not that I really cared too much anyway). What makes it worse is that since it's not using procmail and instead using sieve, sieve has no way of writing to file (that I know of, possibly security reasons) so the ispconfig_mailsize files are no long updated.

    Using dovecot settings, I had written a sieve wrapper which will process the emails sizes and create/append the files upon receiving mail.

    I don't know how the new dovecot support works since 3.0.3 and how many people are using it. The sieve script and wrapper is still a bit quick patched up since I wrote it a while back but if there's interest, I'll release the code/howto.

  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Would be great if you could release that wrapper. Maybe it can be used in ispconfig to solve the mail statistics problem for dovecot servers.
  3. radim_h

    radim_h Member HowtoForge Supporter

    i think it will be not only me thankfull for this!
    i'm using 3.0.3 with dovecot
  4. djtremors

    djtremors ISPConfig Developer ISPConfig Developer

    I have been running it now for months now and so far it's been successful but i only have 1 little issue to resolve and that is that since this is opensource there's the problem that I'm using a localhost email address which is the processing agent (php script) that takes care of counting it.
    The problem itself is that anyone outside can telnet to the server and send heaps of emails to the "[email protected]" or whatever address either to exploit it (attack php itself) or to artificially inject traffic to an account that never got the traffic... if you get what I mean.

    The way I did it is to write a global sieve script which all mailboxes receiving the mail will run this script, it auto forwards the emails to the local scripted alias address which does the processing.

    One solution i thought of is forcing the admin installing the script to generate their own email, possibly using an md5 or something eg. [email protected]
    Then alias from that.

    there's the other thing which I haven't actually checked yet is that if 2 people in the same domain are sent the same email, is it counted as 2x traffic (1 for each) or just the 1.. I believe it's counting as 1 atm...

    any suggestions are helpful. I'll modify and release as I clean it up.
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok, so your approach is similar to what we have used in ispconfig 2. One other solution for dovecot might be to use the dovecot rawlog. I've read about that log but I was not able to test it yet. This log shall contain the mailsize as well.
  6. djtremors

    djtremors ISPConfig Developer ISPConfig Developer

    Yeah at the time I didn't realise the change to dovecot would affect this so when I noticed what was happening and so in the rush to simulate how it was being done in the past was do to the same in dovecot/sieve although couldn't write to a file so opted for an alias script. works well so far.
  7. osterhase

    osterhase New Member

    Hi there,

    any news to this topic? On our servers there is also dovecot running an we are heavily interested in implementing the mailbox-traffic-monitoring feature.

    I did a bit of research and came across the rawlog-feature for dovecot. Maybe it's possible to use that feature instead of sieve-stuff. Had no time to test the feature so far.

    Best regards.
  8. djtremors

    djtremors ISPConfig Developer ISPConfig Developer

    rawlog would be the ideal way as it wouldnt need special permissions or sieve scripting etc.
    Without doubling checking the logs I believe you would have to script it well enough to pickup the size=[0-9]+ value on 1 log line and then chase the recipients names in upcoming lines as it aren't on the same log line entry making it a wee bit trickier. You would have to track the queue id and then find the recipients on the line with the same queue id.
    This is going off memory but whatever the case, it's possible.
  9. osterhase

    osterhase New Member

    Just checked out the rawlog feature - the problem seems to be that those logfiles are simply exploding because they "log" also the attachments sent. So basically I send a couple of test-mails - one containing an attachment - and the dovecot.rawlog directory came up with 500 kb. That seems to be a damn lot of hdd-space (if you think not about one but about one-hundred users).

    I wonder if the mail.log wouldn't be another interesting starting point - I mean awstats is able to log the mailbox traffic.
  10. djtremors

    djtremors ISPConfig Developer ISPConfig Developer

    actually, I was thinking of logtail with a script as most of you probably realised. then you can run it every minute or so and process the mail.log. shouldn't be too hard.
  11. osterhase

    osterhase New Member

    After some research: I've to admit that this is too hard for me. Maybe you pick that up? Otherwise we've to live with awstats log-facilities for the moment.

    Edit: Just came across mysqmail which logs postfix + dovecot /courier + ftp traffic in a mysql-db. Obviously it was also discussed earlier that year here.
    Last edited: Aug 25, 2011

Share This Page