Fast Debian Lenny / Exim4 install

Discussion re sg development. You don't have to be a developer.

Fast Debian Lenny / Exim4 install

Postby cgz » Thu Jan 20, 2011 10:41 pm

This is a howto for the install of spamgourmet on a Debian Lenny server by a root user. It's more or less a copy/paste tutorial... But some prior admin knowledge are required. You will do this install as root, so as privileged user, you should have a basic idea of the system you are working on...

1/ Install the dependencies
Code: Select all
apt-get install exim4 apache2 libapache2-mod-perl2

Accept default options. For exim4, you will have to set it to receive mails from the internet and to send them directly or via a smarthost. Insert the IP address which should be monitored (in place of, and set the other domains that accept emails to your spamgourmet domain (for example Finally, select ?No? to split the configuration file in multiples files.

Now you have a working Exim configuration. You can test it by sending an email to where user is a localuser. Mails should be delivered to the user Maildir or in a mailbox file, depending on your Exim configuration.

2/ Download the spamgourmet source code
Code: Select all
svn co spamgourmet

3/ Copy the files in the right place
Code: Select all
cd spamgourmet
mkdir /usr/local/lib/spamgourmet
cp -R captchasrv mailhandler modules /usr/local/lib/spamgourmet
mkdir /var/www-spamgourmet
mkdir /var/www-spamgourmet/captcha
cp -R web/graphs.cgi web/html/* web/templates /var/www-spamgourmet
mkdir /etc/spamgourmet
cp conf/spamgourmet.config /etc/spamgourmet

4/ Edit the configuration files
Code: Select all
%localdomains = (
'' => 1
$admindomain = '';
$dbstring = 'DBI:mysql:database=XXXdatabaseXXX;host=localhost';
$dbuser = 'XXXuserXXX';
$dbpassword = 'XXXpassXXX';
$debugfilename = '/var/log/spamgourmet.log'; # full path to debug output file
$webapproot = '/var/www-spamgourmet/';
$webtemplatedir = '/var/www-spamgourmet/templates/';
$mailhost = '';
$adminemail = '';
$otherdomainemail = '';

Code: Select all
use lib "/usr/local/lib/spamgourmet/modules";
my $config = Mail::Spamgourmet::Config->new(configfile=>'/etc/spamgourmet/spamgourmet.config');

Code: Select all
<img src="<%imagefilename%>" width="620" height="180" border="0">

Code: Select all
use constant InstallDir => "usr/local/lib/spamgourmet/captchasrv";
use constant   TmpDir => "/var/www-spamgourmet/captcha";

Code: Select all
use lib "/usr/local/lib/spamgourmet/modules";
my $configfile = "/etc/spamgourmet/spamgourmet.config";

To work with Exim4 I also had to change
Code: Select all
$headerValues{'from'} = $ENV{'FROM'};

Code: Select all
$headerValues{'from'} = $ENV{'SENDER'};

5/ Create and setup the database
Code: Select all
mysqladmin -u root -p create XXXdatabaseXXX (name of the database from spamgourmet.config)

Code: Select all
mysql -u root -p
mysql> grant all privileges on XXXdatabaseXXX.* to 'XXXuserXXX'@'localhost' identified by 'XXXpassXXX';
mysql> exit

Code: Select all
mysql -u XXXuserXXX -p XXXdatabaseXXX < conf/db.sql
mysql -u XXXuserXXX -p XXXdatabaseXXX < conf/dialogs.sql

6/ Create a virtualhost
Create the config file: /etc/apache2/sites-available/
Code: Select all
      DocumentRoot /var/www-spamgourmet
      <Directory /var/www-spamgourmet/>
              Options +ExecCGI
              AllowOverride None
              AddHandler cgi-script .cgi .pl
      ErrorLog /var/log/apache2/
      LogLevel warn
      CustomLog /var/log/apache2/ combined
      ServerSignature Off

Activate the virtualhost
Code: Select all

Reload the config
Code: Select all
/etc/init.d/apache2 reload

7/ Configure Exim4
Edit the main configuration file: /etc/exim4/exim4.conf.template

Enable the # character in the localparts (remove it twice):
Code: Select all
CHECK_RCPT_LOCAL_LOCALPARTS = ^[.] : ^.*[@%!/|`&?]
CHECK_RCPT_REMOTE_LOCALPARTS = ^[./|] : ^.*[@%!`&?] : ^.*/\\.\\./

Create a catchall router in the routers section
Code: Select all
  driver = accept
  domains =
  transport = spamg_pipe

Create a transport in the transports section
Code: Select all
  debug_print = "T: spamg_pipe for $local_part@$domain"
  driver = pipe
  command = /usr/local/spamgourmet/mailhandler/spameater

Restart Exim 4
Code: Select all
/etc/init.d/exim4 restart

8/ Start the captcha server
Start the captcha server. This is for tests only! You should start it with a non privileged user and with daemontools or something similar.
Code: Select all
/usr/local/spamgourmet/captchasrv/ &

9/ Test your new spamgourmet server
Open your browser and create a new account:

10/ Customize...
There are a lot of references to in the code... So you will have to tune everything to your needs. A good start is the folder: /var/www-spamgourmet/templates/EN.
To find the relevant parts, you can always use the grep command over the source code ;-)
Posts: 1
Joined: Thu Jan 20, 2011 8:52 pm

Re: Fast Debian Lenny / Exim4 install

Postby cbw1066 » Fri Aug 22, 2014 12:41 pm

Thanks for the excellent tutorial.

I am using postfix and have worked out the config for it but am having problems with the apache end.

I have a few things running on my server (owncloud/squirrelmail) so need to access spamgourmet as but am not sure what to do differently with the apache side of your tutorial.

Any help would be appreciated.


Posts: 1
Joined: Thu Aug 21, 2014 12:32 pm

Re: Fast Debian Lenny / Exim4 install

Postby Josh Parris » Thu Apr 27, 2017 12:02 pm

Things have changed since 2011, but I managed a successful install on Debian Ubuntu 16.04 Xenial Xerus
Josh Parris
Posts: 8
Joined: Tue Apr 18, 2017 7:09 am
Location: Melbourne, Australia

Return to Developers

Who is online

Users browsing this forum: No registered users and 1 guest