Postfixadmin / PostgreSQL / Courier / Squirrelmail / SpamAssassin / ClamAV on Debian Etch (Howto/Tutorial)

What?

This is a quick guide to installing Postfixadmin on a Debian Linux (Etch/4.0) server. I've done a similar guide on this before, but it's getting dated; hence this new one.

This guide also covers installing ClamAV to scan incoming mail and viruses.

If you follow this guide through you should end up with a mail server which can support virtual domains and users, and can be administered through a web browser. Domain specific 'stuff' can be delegated to other administrators if you so wish.

The mail server in question (for a customer of mine) also has Squirrelmail installed, so I've bundled that in too. For historical reasons, the server uses PostgreSQL (rather than MySQL) for it's backend database.

PostfixAdmin is the web based front end through which users and administrators interact with the configuration of the server. Using it you can easily add domains/users/aliases etc to a mail server. It also supports vacation / autoreply support.

Commercial Plug

Pale Purple provide and support Linux mail servers based on a similar configuration. So, if you need a support contract, or more functionality....

Install Debian

No surprise there... I installed Etch via netboot, and ended up with a fairly minimal setup. You'll probably do it a different way. I told it to install as a 'mail server' and a 'web server'. The 'mail server' option was probably a mistake as it installs uw-imapd and exim, neither of which I wanted/needed.

You probably want to install openssh-server and molly-guard :)

Postfix

apt-get install postfix postfix-pgsql

(Or postfix-mysql if you're going to use that instead)

I selected the Internet Site configuration when asked to pick a configuration.

/etc/apt/sources.list

In order to have slightly more recent versions of a few packages (PHP5, ClamAV and PostgreSQL mainly), I added the following into my /etc/apt/sources.list file :

deb http://packages.dotdeb.org stable all
deb http://www.mirrorservice.org/sites/backports.org/ etch-backports main contrib non-free
deb http://volatile.debian.org/debian-volatile etch/volatile main contrib non-free

Install PostgreSQL

I installed PostgreSQL 8.2 from backports.org ...

apt-get install -t etch-backports postgresql-8.2

(Note: there is no requirement on using v8.2, but I'm under the impression that it's faster than previous versions). I'd suggest you use at least v8.1 (in Etch) from a maintenance point of view.

Install PHP5

I always install the suhosin extension to PHP in the hope it will provide extra security. APC (Alternative PHP Cache) is also installed in the expectation it will improve performance.

apt-get install php5 libapache2-mod-php5 php5-pgsql php5-suhosin php5-apc php-pear

(The above packages nearly all come from dotdeb.org)

Install Postfixadmin

Although I have created .deb for Postfixadmin; at the time of writing, v2.2.0 hasn't been released; so I instal Postfixadmin from SVN. Hopefully, we'll release version 2.2.0 of Postfixadmin sometime soon, and you will want to see this page to download it.

cd /var/www 
svn co https://postfixadmin.svn.sourceforge.net/svnroot/postfixadmin/trunk postfixadmin

If you now hit http://your.server/postfixadmin you should see a slightly useful 'welcome' screen, follow the link through to the 'setup.php' page. And you should get some sort of instant gratification that at least something works :) (although some of the checks will fail)

Setting up PostgreSQL (or MySQL)

As postfixadmin stores all of it's configuration within a database, we need to setup the database before we can do much further. You may find that phppgadmin or phpmyadmin help with this.

Basically - create a user (e.g. 'postfix') and a database (e.g. 'postfix'). The user should own the database. Ensure there's a password set on the user.

If security is a concern, you should probably have a user that is 'read-only' which is used by postfix (as it only ever queries the DB) while postfixadmin will need a read-write user account.

If you're using PostgreSQL, the following shows what I typed in from a shell (all lines containing a $ or #)on the server when logged in as root

mail:~# su - postgres
postgres@mail:~$ psql template1
Welcome to psql 8.2.4, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

template1=# CREATE USER postfix WITH PASSWORD 'complexpassword';
CREATE ROLE
template1=# CREATE DATABASE postfix WITH OWNER postfix ENCODING 'UNICODE';
CREATE DATABASE
template1=# \q

If, like me, you are useless at picking passwords, try using pwgen

Load the Postfixadmin Database Schema into your database

As of subversion revision 328, the setup.php script should automatically create the database structure for you. If you are using an older version of PostfixAdmin you'll need to do the following :

cd /var/www/postfixadmin
psql -U postfix -h localhost postfix < DATABASE_PGSQL.TXT 

This may spew out a few errors about roles that don't exist, but it should work

Configuration of Postfixadmin

Edit /var/www/postfixadmin/config.inc.php in your favourite editor (vi[m]).

  1. Change
    $CONF['configured'] = false;

    to

    $CONF['configured'] = true;
  2. Change
    $CONF['postfix_admin_url'] = '';

    to

    $CONF['postfix_admin_url'] = 'http://your.server/postfixadmin';
  3. Change
    $CONF['database_type'] = 'mysql';

    to pgsql (assuming you want PostgreSQL!)

  4. Change the other database parameters to match what you used above.

You'll want to change other parameters, but they're not normally essential

Postfixadmin

Once your config.inc.php file has the right database credentials, and you refresh http://your.server/postfixadmin/setup.php you should some output indicating that the database tables have been created, and also see a dialog box to Create the superadmin account. You should treat these details a bit like the 'root' password for a Unix server. This user will be able to add/remove/edit any domains/users/aliases etc.

Anyway, choose an admin account, this could be (for example) it@your.domain

Submitting this form, successfully, should result in the page giving you a message like 'Admin has been added!'

Delete setup.php (rm setup.php or mv setup.php setup.php.blah)

Configuring Postfix

This always seems to be the bit that causes others trouble....

New configuration files

In my world, the following go in /etc/postfix/pgsql

You'll need to change the xxxxxx's to appropriate values

relay-domains.cf

(Who we relay mail for (as a backup mx))

user            = postfix
password        = xxxxxxx
dbname          = postfix
hosts           = localhost
query = SELECT domain FROM domain WHERE domain = '%s' AND backupmx = true

virtual-alias-maps.cf

(Think: /etc/aliases or similar)

user             = postfix
password         = xxxxxxxx
dbname           = postfix
hosts            = localhost
query = SELECT goto FROM alias WHERE address='%s' AND active = true

virtual-domains.cf

(Domains we accept mail for...)

user        = postfix
password    = xxxxxxxx
dbname      = postfix
hosts       = localhost
query = SELECT domain FROM domain WHERE domain='%s' AND backupmx = false AND active = true

virtual-mailbox-limit-maps.cf

(Only used if you're checking quota etc)

user = postfix
password = xxxxxxx
hosts = localhost
dbname = postfix
query = SELECT quota FROM mailbox WHERE username = '%s'

virtual-mailbox-maps.cf

(What mailboxes exist that we can deliver to)

user      = postfix
password  = xxxxxxxx
dbname    = postfix
hosts     = localhost
query = SELECT maildir FROM mailbox WHERE username='%s' AND active = true

main.cf changes

Add in the following :

# All virtual mailboxes live somewhere in here ..
virtual_mailbox_base = /var/mail/vmail

# The (virtual) domains we accept mail for
virtual_mailbox_domains = proxy:pgsql:/etc/postfix/pgsql/virtual-domains.cf

# Lookup mailbox location, uid and gid based on email address received.
virtual_mailbox_maps = proxy:pgsql:/etc/postfix/pgsql/virtual-mailbox-maps.cf
virtual_uid_maps = static:101
virtual_gid_maps = static:101

virtual_alias_maps = proxy:pgsql:/etc/postfix/pgsql/virtual-alias-maps.cf

relay_domains = proxy:pgsql:/etc/postfix/pgsql/relay-domains.cf
local_transport = virtual
local_recipient_maps = $virtual_mailbox_maps

chown 101 /var/mail/vmail

Postfix SMTP Auth Support

If your users are likely to be trying to send mail through your mail server when they are not on a trusted network, you'll need to add this to /etc/postfix/main.cf

smtpd_sasl_authenticated_header = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes

And in /etc/postfix/sasl/smtpd.conf put the following :

pwcheck_method: saslauthd 
saslauthd_path: /var/run/saslauthd/mux
log_level: 3
mech_list: PLAIN LOGIN

(As you can see, we'll be using SASL as a backend for authentication)

SASL

Thankfully the SASL package works a bit better under Etch than it did under Sarge/etc.

apt-get install sasl2-bin

Edit /etc/default/saslauthd so it has :

MECHANISMS="rimap"
THREADS=5
OPTIONS="-r -c -O localhost -m /var/spool/postfix/var/run/saslauthd"

You'll need to mkdir -p /var/spool/postfix/var/run/saslauthd before SASL will start

(One day, I might change to use the pam_sql module; as this would remove unnecessary IMAP logins... )

Courier

apt-get install courier-authdaemon courier-imap courier-imap-ssl courier-pop courier-pop-ssl courier-authlib-postgresql

Configuring Courier's authdaemon

You'll need to edit /etc/courier/authpgsqlrc (or authmysqlrc if using MySQL)

PGSQL_HOST        localhost
PGSQL_PORT        5432
PGSQL_USERNAME    postfix
PGSQL_PASSWORD    something
PGSQL_DATABASE    postfix
PGSQL_USER_TABLE  mailbox
PGSQL_CRYPT_PWFIELD password
PGSQL_UID_FIELD   '101'
PGSQL_GID_FIELD   '101'
PGSQL_LOGIN_FIELD username
PGSQL_HOME_FIELD  '/var/mail/vmail'
PGSQL_NAME_FIELD  name
PGSQL_MAILDIR_FIELD maildir
PGSQL_QUOTA_FIELD quota

And also edit /etc/courier/authdaemonrc, and set authmodulelist="authpgsql" (or authmysql if you're using MySQL)

If you now create a user in a test domain on postfixadmin, you should be able to connect to your mail server successfully, and receive mail

Basic Testing (pop3)

Assuming you've created a domain, and a user within that domain from Postfixadmin, you should be able to do something like the following :

mail:~# tail -f /var/log/mail.log  &
mail:~# echo 'test email' | mail test@my.domain
mail:~# 
Dec  6 22:31:56 mail postfix/pickup[11888]: A811A2B10063: uid=0 from=<root>
Dec  6 22:31:56 mail postfix/cleanup[11897]: A811A2B10063: message-id=<20071206223156.A811A2B10063@mail.my.domain>
Dec  6 22:31:56 mail postfix/qmgr[11889]: A811A2B10063: from=<root>, size=297, nrcpt=1 (queue active)
Dec  6 22:31:56 mail postfix/virtual[11902]: A811A2B10063: to=<test@my.domain>, relay=virtual, delay=0.11, delays=0.05/0.04/0/0.02, dsn=2.0.0, status=sent (delivered to maildir)
Dec  6 22:31:56 mail postfix/qmgr[11889]: A811A2B10063: removed

Additionally, if you now look in /var/mail/vmail, you should see a folder called 'test@my.domain'. No guesses should be needed to figure out what this contains!

Squirrelmail

Squirrelmail is a mature web based mail client. It's been around for some time now, and thankfully plugins exist for a number of additional "features". As your author patched up the squirrelmail postfixadmin plugin, he's going to take a small amount of time <plug>it.</plug>

  • apt-get install squirrelmail
  • wget http://squirrelmail-postfixadmin.palepurple.co.uk/files/squirrelmail-postfixadmin_2.1.0-1_all.deb
  • dpkg -i squirrelmail-postfixadmin_2.1.0-1_all.deb
  • Edit /etc/squirrelmail/plugins/postfixadmin-config.php - use the same settings from Postfixadmin
  • pear install MDB2
  • pear install MDB2#pgsql (or MDB2#mysql)
  • Run squirrelmail-configure and enable the Postfixadmin plugin

Squirrelmail should be accessible at http://youserver/squirrelmail by default.

ClamAV

This is easiest to integrate via Amavis. You should get ClamAV from dotdeb.org, or Debian volatile via apt-get. Relying on the 'default' clamav shipped with etch is probably not a good idea (and ClamAV will also moan when it tries to update it's definitions list).

apt-get install amavisd-new clamav spamassassin

You'll want to edit

/etc/amavis/50-user

In my case, it looks a bit like :

use strict;

#
# Place your configuration directives here.  They will override those in
# earlier files.
#
# See /usr/share/doc/amavisd-new/ for documentation and examples of
# the directives you can use in this file
#

chomp($myhostname = `hostname`);

$forward_method = 'smtp:127.0.0.1:10025';
# Where to submit notifications
$notify_method = $forward_method;

# Net::Server Pre-forking settings; note max_servers should match Postfix's master.cf..
$max_servers = 5;
$max_requests = 10;
$child_timeout = 5*60; # abort child if it takes longer than x seconds to complete.

# MTA specific settings...
$relayhost_is_client = 0;
$insert_received_line = 1;

$inet_socket_bind = '127.0.0.50';
@inet_acl = qw ( 127.0.0.0/8 );

# How we handle viruses and spam; options being discard, bounce or pass.
$final_virus_destiny = D_DISCARD;
$final_banned_destiny = D_BOUNCE;
$final_spam_destiny = D_PASS;
$final_bad_header_destiny = D_BOUNCE;

# Headers..
$X_HEADER_TAG = 'X-Virus-Scanned';
$X_HEADER_LINE = "by Amavis+SpamAssassin+ClamAV and more at $mydomain";

$remove_existing_x_scanned_headers = 1;
$remove_existing_spam_headers = 1;

$sa_tag_level_deflt  = -99.0;  # add spam info headers if at, or above that level
$sa_tag2_level_deflt = 5.0;
$sa_kill_level_deflt = 5.0; # triggers spam evasive actions

$recipient_delimiter = '+';
$replace_existing_extension = 1;
$localpart_is_case_sensitive = 0;

# SpamAssassin settings
$sa_timeout = 30;
$sa_auto_whitelist = 1;
$sa_local_tests_only = 0;
$sa_spam_modifies_subj = 1;
$sa_spam_subject_tag = '*** SPAM *** ';
$sa_spam_report_header = 1;
$first_infected_stops_scan = 1;
$sa_debug = 1;

$DO_SYSLOG = 0;
$SYSLOG_LEVEL = 'mail.info';
$LOGFILE = "/var/log/amavis.log";

@local_domains_acl = ('.');
#------------ Do not modify anything below this line -------------
1;  # insure a defined return

The above configures Amavis to :

  • Scan and label Spam for all mail that goes through the server (And not just for some specified domains - see @local_domains_acl)
  • Forward scanned mail to 127.0.0.2:10025 for delivery by Postfix
  • Listen for mail (from Postfix) on 127.0.0.50
  • Discard Viruses
  • Remove any existing anti-virus tags etc (as these will be from some.other.system)
  • If SpamAssassin scores more than 5.0, then rewrite the subject etc

Some notes:

  1. SpamAssassin does not need to run via the SpamC/SpamD mechanism - Amavis handles this all internally
  2. Amavis appears to ignore most, if not all, settings you would otherwise set for SpamAssassin in e.g. /etc/spamassassin/local.cf
  3. When I initially started using Amavis it seemed to be a bit clueless when it came to listening and delivering on the same IP address. Perhaps I did something wrong, but nevertheless, this is why it listens on a different IP address (127.0.0.50) to the one it delivers to (127.0.0.1). You don't need to do anything to setup 127.0.0.50 on a Linux box.

Amavis / Postfix Integration

  • Edit /etc/postfix/master.cf
amavis            unix  -       -       -       -       5       smtp
    -o smtp_data_done_timeout=5000
    -o smtp_send_xforward_command=yes
    -o receive_override_options=no_address_mappings

# change or remove the existing smtp definition.
smtp      inet  n       -       -       -       12       smtpd
    -o content_filter=amavis:[127.0.0.50]:10024

# where mail is re-injected back in by Amavis after it's
# done it's stuff.
127.0.0.1:10025 inet    n   -   -   -   - smtpd
    -o smtpd_autorized_xforward_hosts=127.0.0.0/8
    -o smtpd_client_restrictions=
    -o smtpd_helo_restrictions=
    -o smtpd_sender_restrictions=
    -o smtpd_recipient_restrictions=permit_mynetworks,reject
    -o mynetworks=127.0.0.0/8
    -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks,no_address_mappings

Then reload Postfix, make sure Amavis and ClamAV are running (/etc/init.d/amavis start or /etc/init.d/clamav-daemon ) and it should work.

Comments

antivirus and antispam control

Have write a complementary howto to integrate antivirus and antispam control ?

antispam/antivirus

Hi,

No I haven't; but there are many tutorials "out there" which can guide you in the right direction.

David.

updated...

Hi,

I've added in 'stuff' on how to integrate ClamAV + Amavis + SpamAssassin

thanks!

you helped me a lot!
but for the many not-so-experienced users out there (like me...) you shouldn't forget to tell them to restart apache after installation of the php modules...

thanks

there is an error regarding UID 101 / 1001 ...must be the same everywhere

UID / GID error

Maybe they are already in use on your system by another user / group? Those are not set in stone. You can set whatever UID/GID you like, so long as you alter the rest of the config files to match.

-J

Thanks for tutorial! but

Thanks for tutorial!

but some whn trying integrate amavis + clamav + spamassasin, i got this error when try receive or send email from server:
Apr 8 11:58:59 mailsrv postfix/qmgr[16246]: warning: connect to transport custom_filter: No such file or directory

ah, that's because i was chaining content filters

Hi,

I've updated the docs above, essentially I had a stray '-o content_filter=custom_filter' when it [custom_filter] wasn't defined anywhere.

Thanks
David.

amavis issues

Hi,

I've noticed that Amavis can create too many files in /var/lib/amavis/tmp and /var/lib/amavis/virusmails ....

If this is the case you'll see messages like :

Apr 8 13:24:05 youserver /usr/sbin/amavisd-new[5539]: (05539-01) TROUBLE in process_request: Can't create directory /var/lib/amavis/tmp/amavis-20080408T132405-05539: Too many links at /usr/sbin/amavisd-new line 4032, line 4.

This indicates (no surprise) that you've got a directory with too many entries in it (or you've run out of inodes (unlikely)).

The solution is easy enough...

find /var/lib/amavis/tmp -type f -name '*spamassassin*' -print | xargs rm -Rf
find /var/lib/amavis/virusmails -type f '*.gz' | xargs rm -Rf

(Or change your config files to not store the quarantined files)

(I have a feeling the tmp/.spamassassin* files are erronous, and should be cleaned up by SpamAssassin)

MySQL & Sockets

With mysql you might have problems connecting to the db via sockets if you're in a chrooted environment. Therefore you should use "hosts = 127.0.0.1" instead of "hosts = localhost" to force connection via tcp. See also http://www.postfix.org/mysql_table.5.html (Parameter "hosts").

SASL error message

if you for some reason get error message:
warning: xsasl_cyrus_server_get_mechanism_list: no applicable SASL mechanisms

run:
apt-get install libsasl2-modules

it worked for me

YES! That was it

Thank you very much!

I'm running into problems

I'm running into problems somewhere ... I don't know really if I should change sth or not in the part about creating the files at /etc/postfix/pgsql

And I think that is the cause of all my problems right now.

There's another thing I think you should say, when editing /var/www/postfixadmin/config.inc.php users should change also the username and psw. I know this sounds stupid and I didn't have any problems with this, but an unexperienced user will have headaches with this.

There's one last thing, what if you want to have multiple domains? ... what should I change etc. I have no idea.

Thanks for this nice and complete guide.

Hi there, to begin with,

Hi there, to begin with, thanks for this guide.

I would like to say that there are some parts that are not clear enough (for me at least). The intention of this is to make this guide better, I'm not trying to steal you credit or tell you how you should make things.

---------------------

When you edit Edit /var/www/postfixadmin/config.inc.php while configuring postfix, the user should fill in the username, password and database name.

svn is not installed by default in some installations, for example, installing a network version of debian.

While creating the files at /etc/postfix/pgsql it's not clear enough (for me at least) what should be changed or not.

I finished up at the Basic Testing (pop3) part with warnings and errors.

One idea that appears in my head, is that all the things that a user should change or write or anything could be between <<>> for example, or anything else.

Another thing that appears in my head, is what if you want to add more domains, what would you need to edit, change, whatever to have more domains. I get lost at creating the files al /etc/postfix/pgsql.

-----------------------------

Despite that, it's one of the most complete guides I saw out there.

Thanks again, and sorry if I hurt your feelings. Mail me if you want to.

Great

Hi, I welcome all feedback - as long as it's not spammy or too offensive, in which case it never gets published :)

I was mistaken

Well David, I started this guide again, from zero, and ... it went fine, with almost everything (explained below), I think I was misstyping or doing sth stupid round there, maybe because of how sleepy I was.

Now, everything was working beautifull ... installed everything except the Squirrel, and rebooted the machine, checked mail trough Out.Exps using the same admin user created to test.

But, after creating more account's through the Postfix Admin interface, using or no the same domain, gives me an error.
(I'm sure it's not because of the domain)

mail courierpop3login: Connection, ip=[::ffff:192.168.1.122]
mail courierpop3login: chdir name@domain.com/: No such file or directory

Went to the /var/mail/vmail/ and find that there was only the admin folder. It seems it's not creating the folder for the user.

I think this happened after installing the Amavis/SpamAssassin/ClamAv.

Can't see where is the bug. And I'm tired, so no more for today. =)

ah - the classic postfixadmin bug report

Hi,

You need to tell 'it' to send an email to the user when creating a mailbox. Postfixadmin (itself) doesn't have permission to create files within the mail directory. But by sending a welcome message to the user, Postfix creates the mail directory, and everything works.

I am wondering if the option of sending a 'welcome' email should no longer be an option, and instead become mandatory.

About the welcome mail

Well ... after I saw that the folder wasn't created, I went to the postfix admin webpage and sent a welcome mail.

Nothing happened. I'm testing this in a VM, so, I'll tell you tomorrow (if I can) what happens before installing Amavis/ClamAv/SpamAssassin and after.

If you want me to test sth in particular, tell me. I think you can see my mail addres from my posts, mail me if you want.

check the directories

Hi,

Look in /var/log/mail.log - was an email sent to the account, or did it get bounced with an error message?

Look in /var/mail/vmail (or wherever) - does the user's mail directory exist? If not, try 'echo "hello" | mail user@the.domain' in a shell, and see if that shows up in mail.log.

thanks
David.

Checked log

Hi

well ... I've tryed two ways of the welcome mail. Through command line and through postfixadmin.
Through command line I get this

mail postfix/virtual[2368]: 18621A8531: to=, relay=virtual, delay=0.6, delays=0.3/0.12/0/0.18, dsn=2.0.0, status=sent (delivered to maildir)

And the directory is created.

Through postfixadmin I get this

mail postfix/qmgr[2188]: 3AFBBA852C: to=, relay=none, delay=0.09, delays=0.07/0.02/0/0, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to 127.0.0.50[127.0.0.50]: Connection refused)

And of course, the directory isn't created.

So, to check my thought's ... went to /etc/postfix/master.cf and commented the added parts and restored the original smtpd line.

Then went to postfixadmin and sent again a mail to the mailbox that had no directory created. The directory was created.

I think it might be an option of amavis or sth like that. =)

and thank you.
Leo.

amavis to blame!

it looks like your amavis isn't listening on 127.0.0.50....

check /etc/amavis/conf.d/50_user.cf contains "$inet_socket_bind = '127.0.0.50';" and is running.
"

Discovery

David ... I'm really sorry to say this, but in the guide, in the ClamAv section you put that we should edit /etc/amavis/50-user .... when is /etc/amavis/conf.d/50_user.cf

I edited the file, etc. But I checked if amavis whas running, to my surprise, no. So I tryed to start it, and gives me this error

Starting amavisd: The value of variable $myhostname is "mail", but should have been
a fully qualified domain name; perhaps uname(3) did not provide such.
You must explicitly assign a FQDN of this host to variable $myhostname
in amavisd.conf, or fix what uname(3) provides as a host's network name!
(failed).

What amavis says is correct, my hostname is mail and the domain is what goes after @ ...
So I changed the domain in 50_user.cf to my domain ... as 'mail.mydomain.com' and it worked. =D

I don't really know if I should name my machine in other way, what do you think ?

The definitive solution

The definitive solution is to put change this line

chomp($myhostname = '127.0.0.1');

And that's all. =D

Thanks David for everything.

Compressed files

If users want to scan for virus inside compressed files, you may want to run this

apt-get install bzip2 cabextract arj arc zoo lzop tnef pax unrar-free

It installs support for almost all compressed files.

David, thanks for this guide again.

mailman

I find your copy and paste tutorial excellent, thank you.

Have you any tips about configuring mailman here ? (I should find it very usefull)

alias to multiple account

I currently use a syteme where you can redirect one mail to multiple mails account :

adress | goto
a@example.com | b@example.com,c@example.com,d@example.com

postfixadmin prevent it (by the webadmin), it can be a great feature....

you can do this in postfixadmin

strangely (!?) you need to create an alias, and then go and edit it. When you do this, you'll be able to enter multiple addresses.

alias and redirect

We can create an alias, but if the original account is kept on the list, other accounts will receive the message 2 times. Does anybody know how to manage it ??

alias expansion

it sounds like you're processing alias expansion twice...

I'd check to see if you have 'receive_override_options=no_address_mappings' missing from one of your filter definitions.

Squirrelmail & Changing password

Many thanks for this tutorial! Everything works great except in Squirrelmail, I can't change my mail password.
I get:

Could not connect to the database: MDB2 Error: not found

Any ideas on how to fix?

-Tom

err..

Have you installed the appropriate PEAR class ?

pear install MDB2_driver_mysql or MDB2_driver_pgsql ?

re: err..

I ran 'pear install MDB2#pgsql' and it installed, but Squirrelmail refused to use the otherstuff in the database (like addressbook and userprefs) until I installed DB. (But the userprefs doesn't even seem to work, just the address book, but that's beside the point.)

'pear install MDB2_driver_pgsql' just gives me:
Ignoring installed package pear/MDB2_driver_pgsql
Nothing to install

So it appears to be installed, Squirrelmail isn't using it for some reason?

fuzzy brain

I thought it configured itself by reading the config.inc.php file from Postfixadmin - do you need to edit it to tell it where to find config.inc.php or anything?

Squirrelmail & Changing password

I checked /etc/squirrelmail/plugins and there is indeed a postfixadmin-config.php file there with the right postfixadmin values.
However, any attempt to change the password still gives:

Could not connect to the database: MDB2 Error: not found

Even though I have MDB2 pgsql installed.

Tom

re: Could not connect to the database: MDB2 Error: not found

I get the "Could not connect to the database: MDB2 Error: not found" when trying to set up Forwarding and Auto Response as well.
I noticed the Config file for squirrel mail is version 1.4.0 even though Squirrelmail itself is at 1.4.9.

Perhaps there's some step missing in the setup of Squirrelmail?

perhasp your include path is wrong?

Try editing the .php script and print out your include path ... e.g.

echo ini_get('include_path');

And make sure that matches reality...

include_path

It comes up as:

.:/usr/share/php

Now, /usr/share/php has a MDB2.php file in it as well as a MDB2 subdirectory.

Fix

you need to change $CONF['database_type'] = 'postgres' to $CONF['database_type'] = 'pgsql' in the postfixadmin file in /etc/squirrelmail/plugins/postfixadmin-config.php

make sure your database details are correct

what password?

Hi There,

Cheers for the tutorial mate, its awesome to see such an indepth write up for us nubs out there.

One thing though that im running into, is the following part: Configuring Postfix

I under stand that you are using pgsql and i am using MySql which i can handle, but you go onto say that the XXXXX needed to be replaced by my own values, what password am i meant to be using for these XXXX's? is this the password that was created for the database or what? im kinda confused, if you could let me know, thatd be fantastic

Cheers,

Michael

yes - it's the db password

it's for postfix to connect to your database - so yes, it has to be the password for the db user you created.

For all you wide-screen users out there

Nice howto - really - but what a pain in the neck to read it on an ordinary screen.
I always had the impression that when you place something on the net it mainly is there for others to read.

slightly puzzled
mykey

Wide-screen reasons

ok - it's the 'pre' tag in this line that causes the whole text to look like that:

Dec 6 22:31:56 mail postfix/virtual[11902]: A811A2B10063: to=, relay=virtual, delay=0.11, delays=0.05/0.04/0/0.02, dsn=2.0.0, status=sent (delivered to maildir)

in the 'Basic Testing (pop3)' section.

Maybe a < /br> could be added somewhere in there.

mykey

perhaps, perhaps, perhaps ....

perhaps i could put in a div with scrollbars or something.

Can't login Squirrelmail

Hi,
Thank's for great Tutorial
When login in http://localhost/squirrelmail
On the browser I seen error "Unknown user or password incorect"
and in terminal konsole it's look like this
mailtf:~# tail -f /var/log/mail.log
May 31 21:11:48 mailtf imapd: authentication error: Input/output error
May 31 23:10:11 mailtf imapd: Connection, ip=[::ffff:127.0.0.1]
May 31 23:10:11 mailtf imapd: LOGIN FAILED, user=kom@himatifa.org, ip=[::ffff:127.0.0.1]
May 31 23:10:16 mailtf imapd: LOGOUT, ip=[::ffff:127.0.0.1], rcvd=54, sent=332
Jun 1 02:07:31 mailtf imapd: Connection, ip=[::ffff:127.0.0.1]
Jun 1 02:07:31 mailtf imapd: LOGIN FAILED, user=kom@himatifa.org, ip=[::ffff:127.0.0.1]
Jun 1 02:07:36 mailtf imapd: LOGOUT, ip=[::ffff:127.0.0.1], rcvd=54, sent=332
Jun 1 02:08:17 mailtf imapd: Connection, ip=[::ffff:127.0.0.1]
Jun 1 02:08:17 mailtf imapd: LOGIN FAILED, user=nunk@abc.com, ip=[::ffff:127.0.0.1]
Jun 1 02:08:22 mailtf imapd: LOGOUT, ip=[::ffff:127.0.0.1], rcvd=47, sent=332

On /var/mail/vmail user and password input in login was added but I'm still can't login
I has been change owner by set chown 101 /var/mail/vmail
Postfixadmin and in the database its look fine
Can you help me fix this error

does imap work?

It's unlikely to be a squirrelmail issue, it's more likely your imap server isn't configured correctly.

Dont forget smtpd_recipient_restrictions in main.cf

ok very well documented thank you , but for success smtpd authentication,
you must add these lines to end of the main.cf

smtpd_recipient_restrictions =
permit_sasl_authenticated,
permit_mynetworks,
check_relay_domains

Best regards.

OMG, that was totally it

I hadn't read this comment (there are many!) before posting my question re: SASL auth problems - this was totally the key.

THANK YOU.

Hi, You should add the SQL

Hi,

You should add the SQL commands to create the tables. This is useful for people who want to ommit the Postfix Admin step, like me.

err..

I'm not sure why you'd want to omit using a tool to populate the tables; going in using e.g. phpmyadmin or phppgadmin wouldn't be much fun.

Because I want to use my own

Because I want to use my own system for this. Currently I am still using webmin but later I will use my own php system to add users to the mail database.

Port 25 blocked

Hi,

Really great guide... but iam stuck with a small problem...

My ISP have blocked port 25 how do i set up an alternative port?

//Johan

port 25 block solutions

Hi,

Presumably they won't let you send _out_ on port 25 - in which case, you need to find a server to relay through (e.g. a virtual machine etc) or your ISP may provide a server.

Normally it's just a case of doing the following in main.cf:

relayhost = mail.myisp.com

If you wish to relay out through your own machine elsewhere, you might need to do :

relayhost = mail.myotherserver.com:2525

And configure Postfix on mail.myotherserver.com to listen on port 2525 (see master.cf)

Port 25 blocked

see... http://www.5dollarwhitebox.org/wiki/index.php/Howtos_Basic_IPTables#Port_Redirects

basically...

iptables -t nat -A PREROUTING -d your.mailserver.ipaddr.here -p tcp --dport 26 -j REDIRECT --to-ports 25

then connect via port 26

SASL authentication failure: cannot connect to saslauthd server:

Thanks for the guide... it's helping a lot with the setup of my new server.
Ihave walked this path before, but hoped that the SASL problem was a thing of the past...

After installing everything pretty much as described (using mysql) on Ubuntu dapper,
I am getting the following problem with SASL authentication

SASL authentication failure: cannot connect to saslauthd server: No such file or directory
warning: SASL authentication failure: Password verification failed
warning: unknown[##.##.##.##]: SASL PLAIN authentication failed: generic failure

Is this the old crypted password problem... if I remember correctly sasl needed to be recompiled to get around this
any help much appreciated!

Also, I am interested in integrating tls, maildrop filtering and amavis control via squirrelmail plugins,
once I get this auth working, I will post the configs in the comments here...

Problem encountered on following the guide

Hi David,

Vserver - Virtual Machine
Host - Debian Etch 4.0
Guest - Debian Etch 4.0

Thanks for your nice guide. I was following its steps to proceed building a mail server on Guest and encountered following problems.

1)
Install Postfixadmin

vserver4:/var/www# svn co https://postfixadmin.svn.sourceforge.net/svnroot/postfixadmin/trunk postfixadmin
Error validating server certificate for 'https://postfixadmin.svn.sourceforge.net:443':
- The certificate is not issued by a trusted authority. Use the
fingerprint to validate the certificate manually!
Certificate information:
- Hostname: *.svn.sourceforge.net
- Valid: from Tue, 09 Oct 2007 14:15:07 GMT until Mon, 08 Dec 2008 15:15:07 GMT
- Issuer: Equifax Secure Certificate Authority, Equifax, US
- Fingerprint: fb:75:6c:40:58:ae:21:8c:63:dd:1b:7b:6a:7d:bb:8c:74:36:e7:8a
(R)eject, accept (t)emporarily or accept (p)ermanently? p
Checked out revision 461.
* end *

I found "svnroot" not existing. "truck" is on http://postfixadmin.svn.sourceforge.net/viewvc/postfixadmin/trunk

vserver4:/var/www# svn co http://postfixadmin.svn.sourceforge.net/viewvc/postfixadmin/trunk postfixadmin
svn: PROPFIND request failed on '/viewvc/postfixadmin/trunk'
svn: PROPFIND of '/viewvc/postfixadmin/trunk': 302 Found (http://postfixadmin.svn.sourceforge.net)
* end *

Still failed.

2)
Setting up PostgreSQL

(PostgreSQL is new to me. Most times I run MySQL. Just for following your steps described on the guide)

postgresql-8.3 was installed on the backports

vserver4:/# apt-cache policy postgresql-8.3
postgresql-8.3:
Installed: 8.3.3-1~bpo40+1
Candidate: 8.3.3-1~bpo40+1
Version table:
*** 8.3.3-1~bpo40+1 0
1 http://www.backports.org etch-backports/main Packages
1 http://www.mirrorservice.org etch-backports/main Packages
100 /var/lib/dpkg/status
* end *

vserver4:/# su - postgres

postgres@vserver4:~$ psql template1
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
* end *

# ls -al /var/run/postgresql/
total 8
drwxrwsr-x 2 postgres postgres 4096 2008-09-09 06:18 .
drwxr-xr-x 6 root root 4096 2008-09-11 02:24 ..

No socket found.

postgres@vserver4:~$ ps aux | grep postgres
postgres 11423 0.0 0.0 22832 1120 pts/1 S 02:50 0:00 su - postgres
postgres 11424 0.0 0.0 10748 2052 pts/1 S 02:50 0:00 -su
postgres 11545 0.0 0.0 8444 940 pts/1 R+ 02:52 0:00 ps aux
postgres 11546 0.0 0.0 2728 540 pts/1 S+ 02:52 0:00 grep postgres
* end *

postgreSQL seems running.

Please help. TIA

B.R.
satimis

solutions

Hi,

1) https://postfixadmin.svn.sourceforge.net/svnroot/postfixadmin/trunk definately does exist; and is the URL you should svn checkout from; the other URL won't work (although you can view the code through it, it's not an interface to subversion for the 'svn' command line tool).

2) PostgreSQL isn't running - try /etc/init.d/postgresql start

3) "dpkg -l | grep postgres" will show what versions of PostgreSQL are installed.

4) You may find it easier to install the .deb which is available from sourceforge for the project (rather than using subversion).

Thanks
David.

Amavis-new not catching spam

Thanks for the great guide, it has formed the core of my setup, I have set up things pretty much as stated (also trying to integrate maildrop and amavisnew/serverside filter plugins for squirrelmail)

However, I am having a problem with what looks like amavis-new not actually testing for spam. The log returns:

Passed CLEAN, [--.--.--.--] -> , Message-ID: , mail_id: lxT6kPjv8Iw4, Hits: -, 156 ms

The "Hits: -" means that a null result is returned from the spam filter. I have tried playing around with the settings, for instance disabling auto-whitelisting but to no avail... any ideas how to fix this?

it sounds familiar

Does adding :

@local_domains_acl = ('.');

To amavis's config file fix it?

(Turn amavis's logging up... i'm sure that'll help)

David

Better way to get newest amavis

I found out that if you enable the ubuntu universe security despository, apt-get will install a much more recent version of clamav. Easier than using debian universe as this sometimes causes prolems with cross-dependencies.

Uncomment/add these to your /etc/apt/sources.list:

deb http://security.ubuntu.com/ubuntu dapper-security universe
deb-src http://security.ubuntu.com/ubuntu dapper-security universe

Relay Denied issues

I've been over and over this (extremely helpful!) tutorial, and I have gotten everything working EXCEPT sending mail from untrusted networks. Monitoring the mysql log, I can see the queries firing off as expected from the contents of the various postfix .cf files, I fixed a permission denied issue with saslauthd, and I don't know how to methodically troubleshoot these relay denied errors.

Any advice / directions to a starting point to figure this out? As I said, I have everything else working a-ok.

Thanks for a great tutorial!

Bryan

Post new comment

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
Et tu Roboto?