Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOWTO: exim4 and mailgraph
View unanswered posts
View posts from last 24 hours

Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message

Joined: 06 Feb 2003
Posts: 281
Location: Zurich, Switzerland

PostPosted: Sat Jul 08, 2006 11:20 am    Post subject: HOWTO: exim4 and mailgraph Reply with quote

Hi folks,

this morning I wanted to get mailgraph (which is originally intended for Postfix/Sendmail) to work as I wasn't able to find a comparable tool for exim4.

If someone would like to provide a nice ebuild for this please post it to bugzilla ( and a reference in this thread.

Anyway: Have fun! :-)

Step 0:
Install apache(2) with perl/cgi support and configure it according to your needs (not covered in this HOWTO).

Step 1:
Install the dependencies:
emerge Date-Calc File-Tail rrdtool

Step 2:
Download the mailgraph_1.4exim-1_all.deb Debian package from

Step 3:
Create the mailgraph user/group and add the mailgraph user to the mail group:
useradd mailgraph
groupadd mailgraph
usermod -g mailgraph -G mail mailgraph

Step 4:
Use (as I did) mc with its dpkg plugin to extract the following files/directories from the Debian package to the appropriate target directories and set permissions (to minimize the impact of this manual = non-portage approach on the system I didn't include the docs here):
CONTENTS/usr/lib/cgi-bin/mailgraph.cgi -> /var/www/localhost/cgi-bin/mailgraph.cgi
CONTENTS/usr/sbin/ -> /usr/sbin/

cd /var/lib/
mkdir mailgraph
chown mailgraph:mailgraph mailgraph

Step 5:
Create the following file as /etc/conf.d/mailgraph:
# Location of logfile that exim logs to.
# mailgraph defaults to /var/log/syslog if unspecified

# Specify any extra options here.
# If MG_EXIM_LOG is in metalog format, add "-t metalog" to MG_OPTS

Step 6:
Create the following initscript as /etc/init.d/mailgraph:
# Copyright 2006 Andreas Bulling
# Distributed under the terms of the GNU General Public License v2


depend() {
        need exim

start() {
        ebegin "Starting mailgraph daemon"

        # read exim log messages somewhere other than /var/log/syslog?
        [[ -n "${MG_EXIM_LOG}" ]] && MG_OPTS="${MG_OPTS} -l ${MG_EXIM_LOG}"

        start-stop-daemon --start --quiet --background \
            --chuid "$user" \
            --pidfile "$pidfile" --make-pidfile \
            --exec "$daemon" -- --daemon --daemon-rrd="$datadir" --exim ${MG_OPTS}

        eend ${?}

stop() {
        ebegin  "Stopping mailgraph daemon"

        start-stop-daemon --stop --pidfile "$pidfile" &&
            rm -f "$pidfile"

        eend ${?}

This script doesn't work at the moment - if you know how to fix it please let me know ;)

Instead you can add the following line to /etc/conf.d/local.start
to have mailgraph started automatically at boot time:

/usr/bin/perl -w /usr/sbin/ -l /var/log/exim/main.log -d --daemon-rrd=/var/lib/mailgraph --exim

Step 7:
Create the directory /var/run/mailgraph and set appropriate permissions:
cd /var/run/
mkdir mailgraph
chown mailgraph:mailgraph mailgraph

Step 8:
Modify the exim configuration file /etc/exim/exim.conf and add appropriate log_message directives in the different acl sections.
The possible values for log_message are:

For example for the acl_check_data section:
  deny    message = This message contains a MIME error ($demime_reason)
          demime = *
          condition = ${if >{$demime_errorlevel}{2}{1}{0}}
          log_message = MIME_ERROR

  deny    message = This message has been rejected because it contains a virus or malware ($malware_name)
          demime = *
          malware = */defer_ok
          log_message = MALWARE

Step 9 (final):
Start mailgraph and restart exim:
/etc/init.d/mailgraph start
/etc/init.d/exim reload

Please, also have a look at:
Global Marshall Plan Initiative
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum