[exim] realtime logging local delivery into mysql

Top Page
Delete this message
Reply to this message
Author: Mark Elkins
Date:  
To: exim-users
Subject: [exim] realtime logging local delivery into mysql
I'm trying to log various info into mysql at the point of delivery.

I'm trying to do this real time.
I'm just interested (at the moment) in collecting stats on my local
users.
Its a Virtual Domain environment with a 1000 odd users - already in
mysql.

So far - in transports - I have...

mysql_delivery:
  driver = appendfile
  directory = /var/spool/mail/$domain/$local_part/
  maildir_format = true
  user = smmsp
  group = smmsp
  mode = 0660
  quota = 20M
# quota = ${lookup mysql {select quota from admin \
#    where user='${local_part}@${domain}' and status>1}} \
quota_is_inclusive=false


message_suffix = ${lookup mysql {insert into maillog set
mfrom='${quote_mysql:$sender_address}', mto='${quote_mysql:$local_part}@
${domain}',\
    mvia='${quote_mysql:$sender_host_address}', msize=${message_size},
mdelivered=current_timestamp, mailid='dunno', mspam='$spam_score_int',\
    mreturn='${quote_mysql:$return_path}' }{}{}}



This logs quite well - but is obviously a cludge...

1 - I shouldn't be using 'message_suffix' - but needed a variable that
transports/appendfile would allow me to tack an MySql query on to (the
reason that there is {}{} at the end is to not actually append anything
on to e-mails received!) - what should I use?

2 - Problem with Variables - '$spam_score_int' is not documented
anywhere ('$spam_score' doesn't work!) - where does one find a
definitive list of variables - I'd like to add the MailID that exim uses
in the text log file - so can do tie-ups if needed.

3 - With the above delivery - its a modified 'mailbox' delivery - when a
new domain is added for the first time, permissions and ownership (of
$domain) is not what I want (755/smmsp:) - how should the code look?
(have not found many examples for maildir+virtual domain delivery...)


-- 
  .  .     ___. .__      Posix Systems - Sth Africa.  e.164 VOIP ready
 /| /|       / /__       mje@???  -  Mark J Elkins, Cisco CCIE
/ |/ |ARK \_/ /__ LKINS  Tel: +27 12 807 0590  Cell: +27 82 601 0496