Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (Debian Lenny) - Page 2

5 Configure Postfix

Now we have to tell Postfix where it can find all the information in the database. Therefore we have to create six text files. You will notice that I tell Postfix to connect to MySQL on the IP address 127.0.0.1 instead of localhost. This is because Postfix is running in a chroot jail and does not have access to the MySQL socket which it would try to connect if I told Postfix to use localhost. If I use 127.0.0.1 Postfix uses TCP networking to connect to MySQL which is no problem even in a chroot jail (the alternative would be to move the MySQL socket into the chroot jail which causes some other problems).

Please make sure that /etc/mysql/my.cnf contains the following line:

vi /etc/mysql/my.cnf

[...]
bind-address            = 127.0.0.1
[...]

If you had to modify /etc/mysql/my.cnf, please restart MySQL now:

/etc/init.d/mysql restart

Run

netstat -tap | grep mysql

to make sure that MySQL is listening on 127.0.0.1 (localhost.localdomain):

server1:/usr/src# netstat -tap | grep mysql
tcp        0      0 localhost.localdo:mysql *:*                     LISTEN      4559/mysqld
server1:/usr/src#

Now let's create our six text files.

vi /etc/postfix/mysql-virtual_domains.cf

user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT domain AS virtual FROM domains WHERE domain='%s'
hosts = 127.0.0.1

vi /etc/postfix/mysql-virtual_forwardings.cf

user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT destination FROM forwardings WHERE source='%s'
hosts = 127.0.0.1

vi /etc/postfix/mysql-virtual_mailboxes.cf

user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/') FROM users WHERE email='%s'
hosts = 127.0.0.1

vi /etc/postfix/mysql-virtual_email2email.cf

user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT email FROM users WHERE email='%s'
hosts = 127.0.0.1

vi /etc/postfix/mysql-virtual_transports.cf

user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT transport FROM transport WHERE domain='%s'
hosts = 127.0.0.1

vi /etc/postfix/mysql-virtual_mailbox_limit_maps.cf

user = mail_admin
password = mail_admin_password
dbname = mail
query = SELECT quota FROM users WHERE email='%s'
hosts = 127.0.0.1

Then change the permissions and the group of these files:

chmod o= /etc/postfix/mysql-virtual_*.cf
chgrp postfix /etc/postfix/mysql-virtual_*.cf

Now we create a user and group called vmail with the home directory /home/vmail. This is where all mail boxes will be stored.

groupadd -g 5000 vmail
useradd -g vmail -u 5000 vmail -d /home/vmail -m

Next we do some Postfix configuration. Go sure that you replace server1.example.com with a valid FQDN, otherwise your Postfix might not work properly!

postconf -e 'myhostname = server1.example.com'
postconf -e 'mydestination = server1.example.com, localhost, localhost.localdomain'
postconf -e 'mynetworks = 127.0.0.0/8'
postconf -e 'message_size_limit = 30720000'
postconf -e 'virtual_alias_domains ='
postconf -e 'virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, mysql:/etc/postfix/mysql-virtual_email2email.cf'
postconf -e 'virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf'
postconf -e 'virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf'
postconf -e 'virtual_mailbox_base = /home/vmail'
postconf -e 'virtual_uid_maps = static:5000'
postconf -e 'virtual_gid_maps = static:5000'
postconf -e 'smtpd_sasl_auth_enable = yes'
postconf -e 'broken_sasl_auth_clients = yes'
postconf -e 'smtpd_sasl_authenticated_header = yes'
postconf -e 'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination'
postconf -e 'smtpd_use_tls = yes'
postconf -e 'smtpd_tls_cert_file = /etc/postfix/smtpd.cert'
postconf -e 'smtpd_tls_key_file = /etc/postfix/smtpd.key'
postconf -e 'transport_maps = proxy:mysql:/etc/postfix/mysql-virtual_transports.cf'
postconf -e 'virtual_create_maildirsize = yes'
postconf -e 'virtual_maildir_extended = yes'
postconf -e 'virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_limit_maps.cf'
postconf -e 'virtual_mailbox_limit_override = yes'
postconf -e 'virtual_maildir_limit_message = "The user you are trying to reach is over quota."'
postconf -e 'virtual_overquota_bounce = yes'
postconf -e 'proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps'

Afterwards we create the SSL certificate that is needed for TLS:

cd /etc/postfix
openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 365 -x509

Country Name (2 letter code) [AU]: <-- Enter your Country Name (e.g., "DE").
State or Province Name (full name) [Some-State]:
<-- Enter your State or Province Name.
Locality Name (eg, city) []:
<-- Enter your City.
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
<-- Enter your Organization Name (e.g., the name of your company).
Organizational Unit Name (eg, section) []:
<-- Enter your Organizational Unit Name (e.g. "IT Department").
Common Name (eg, YOUR name) []:
<-- Enter the Fully Qualified Domain Name of the system (e.g. "server1.example.com").
Email Address []:
<-- Enter your Email Address.

Then change the permissions of the smtpd.key:

chmod o= /etc/postfix/smtpd.key

 

6 Configure Saslauthd

First run

mkdir -p /var/spool/postfix/var/run/saslauthd

Then edit /etc/default/saslauthd. Set START to yes and change the line OPTIONS="-c -m /var/run/saslauthd" to OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r":

vi /etc/default/saslauthd

#
# Settings for saslauthd daemon
# Please read /usr/share/doc/sasl2-bin/README.Debian for details.
#

# Should saslauthd run automatically on startup? (default: no)
START=yes

# Description of this saslauthd instance. Recommended.
# (suggestion: SASL Authentication Daemon)
DESC="SASL Authentication Daemon"

# Short name of this saslauthd instance. Strongly recommended.
# (suggestion: saslauthd)
NAME="saslauthd"

# Which authentication mechanisms should saslauthd use? (default: pam)
#
# Available options in this Debian package:
# getpwent  -- use the getpwent() library function
# kerberos5 -- use Kerberos 5
# pam       -- use PAM
# rimap     -- use a remote IMAP server
# shadow    -- use the local shadow password file
# sasldb    -- use the local sasldb database file
# ldap      -- use LDAP (configuration is in /etc/saslauthd.conf)
#
# Only one option may be used at a time. See the saslauthd man page
# for more information.
#
# Example: MECHANISMS="pam"
MECHANISMS="pam"

# Additional options for this mechanism. (default: none)
# See the saslauthd man page for information about mech-specific options.
MECH_OPTIONS=""

# How many saslauthd processes should we run? (default: 5)
# A value of 0 will fork a new process for each connection.
THREADS=5

# Other options (default: -c -m /var/run/saslauthd)
# Note: You MUST specify the -m option or saslauthd won't run!
#
# WARNING: DO NOT SPECIFY THE -d OPTION.
# The -d option will cause saslauthd to run in the foreground instead of as
# a daemon. This will PREVENT YOUR SYSTEM FROM BOOTING PROPERLY. If you wish
# to run saslauthd in debug mode, please run it by hand to be safe.
#
# See /usr/share/doc/sasl2-bin/README.Debian for Debian-specific information.
# See the saslauthd man page and the output of 'saslauthd -h' for general
# information about these options.
#
# Example for postfix users: "-c -m /var/spool/postfix/var/run/saslauthd"
#OPTIONS="-c -m /var/run/saslauthd"
OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r"

Then create the file /etc/pam.d/smtp. It should contain only the following two lines (go sure to fill in your correct database details):

vi /etc/pam.d/smtp

auth    required   pam_mysql.so user=mail_admin passwd=mail_admin_password host=127.0.0.1 db=mail table=users usercolumn=email passwdcolumn=password crypt=1
account sufficient pam_mysql.so user=mail_admin passwd=mail_admin_password host=127.0.0.1 db=mail table=users usercolumn=email passwdcolumn=password crypt=1

Next create the file /etc/postfix/sasl/smtpd.conf. It should look like this:

vi /etc/postfix/sasl/smtpd.conf

pwcheck_method: saslauthd
mech_list: plain login
allow_plaintext: true
auxprop_plugin: mysql
sql_hostnames: 127.0.0.1
sql_user: mail_admin
sql_passwd: mail_admin_password
sql_database: mail
sql_select: select password from users where email = '%u'

Next add the postfix user to the sasl group (this makes sure that Postfix has the permission to access saslauthd):

adduser postfix sasl

Then restart Postfix and Saslauthd:

/etc/init.d/postfix restart
/etc/init.d/saslauthd restart

 

7 Configure Courier

Now we have to tell Courier that it should authenticate against our MySQL database. First, edit /etc/courier/authdaemonrc and change the value of authmodulelist so that it reads:

vi /etc/courier/authdaemonrc

[...]
authmodulelist="authmysql"
[...]

Then make a backup of /etc/courier/authmysqlrc and empty the old file:

cp /etc/courier/authmysqlrc /etc/courier/authmysqlrc_orig
cat /dev/null > /etc/courier/authmysqlrc

Then open /etc/courier/authmysqlrc and put the following lines into it:

vi /etc/courier/authmysqlrc

MYSQL_SERVER localhost
MYSQL_USERNAME mail_admin
MYSQL_PASSWORD mail_admin_password
MYSQL_PORT 0
MYSQL_DATABASE mail
MYSQL_USER_TABLE users
MYSQL_CRYPT_PWFIELD password
#MYSQL_CLEAR_PWFIELD password
MYSQL_UID_FIELD 5000
MYSQL_GID_FIELD 5000
MYSQL_LOGIN_FIELD email
MYSQL_HOME_FIELD "/home/vmail"
MYSQL_MAILDIR_FIELD CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/')
#MYSQL_NAME_FIELD
MYSQL_QUOTA_FIELD quota

During the installation, the SSL certificates for IMAP-SSL and POP3-SSL are created with the hostname localhost. To change this to the correct hostname (server1.example.com in this tutorial), delete the certificates...

cd /etc/courier
rm -f /etc/courier/imapd.pem
rm -f /etc/courier/pop3d.pem

... and modify the following two files; replace CN=localhost with CN=server1.example.com (you can also modify the other values, if necessary):

vi /etc/courier/imapd.cnf

[...]
CN=server1.example.com
[...]

vi /etc/courier/pop3d.cnf

[...]
CN=server1.example.com
[...]

Then recreate the certificates...

mkimapdcert
mkpop3dcert

... and restart Courier:

/etc/init.d/courier-authdaemon restart
/etc/init.d/courier-imap restart
/etc/init.d/courier-imap-ssl restart
/etc/init.d/courier-pop restart
/etc/init.d/courier-pop-ssl restart

By running

telnet localhost pop3

you can see if your POP3 server is working correctly. It should give back +OK Hello there. (Type quit to get back to the Linux shell.)

server1:/etc/courier# telnet localhost pop3
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Hello there.
quit
+OK Better luck next time.
Connection closed by foreign host.
server1:/etc/courier#

 

8 Modify /etc/aliases

Now we should open /etc/aliases. Make sure that postmaster points to root and root to your own username or your email address, e.g. like this:

vi /etc/aliases

[...]
postmaster: root
root: postmaster@yourdomain.tld
[...]

or like this (if administrator is your own username):

[...]
postmaster: root
root:   administrator
[...]

Whenever you modify /etc/aliases, you must run

newaliases

afterwards and restart Postfix:

/etc/init.d/postfix restart

Share this page:

45 Comment(s)

Add comment

Comments

From: at: 2009-03-12 04:20:33

how can i write one script after user run this script they log in to root user?

 This script contain username and password of root.

 

 

From: sektalah at: 2010-06-22 14:10:31

Help me please...

How to integrated with postfixadmin...

 I'm try and ...

Error connection DROPED by IMAP

Thank's 

From: rieschl at: 2009-04-11 21:32:28

You should consider changing the permission of the "/etc/postfix/sasl/smtpd.conf" and "/etc/pam.d/smtp" files (chmod o= [filename]) so that the mysql mail-admin-password is not world-readable.

From: at: 2009-11-15 09:10:49

On Mail Clients (Outlook etc.) can the option SMTP Authentification not be activated. Is that correct?

From: Anonymous at: 2010-03-08 17:45:07

cuando entro por el telnet al puerto 25 me da el siguiente error:

 Trying 192.168.1.4...
Connected to 192.168.1.4.
Escape character is '^]'.
+OK Hello there.
user eduardo
+OK Password required.
pass eduardo
-ERR Login failed.

 he seguido el tutorial al pie de la letra, incluso lo hice dos veces, pero me sigue dando error

¿que puedo hacer?

From: Anonymous at: 2010-03-08 15:57:51

seguí los pasos al pie de la letra, pero cuando hago lo siguiente: Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. +OK Hello there. user eduardo +OK Password required. pass eduardo -ERR Login failed. ¿que puedo hacer? Saludos

From: Anonymous at: 2009-03-09 14:02:55

pls update dcc-dccproc

cd dcc-dccproc-1.3.103 acctually

From: White at: 2009-08-27 20:13:48

cd dcc-dccproc-1.3.102 this is now cd dcc-dccproc-1.3.115

 Falko it may be worth placing a note in the instructions that say check to see what level this program is and update the text prior to entering it into the shell.

White

From: hstoellinger at: 2009-11-17 10:19:22

cd dcc-dccproc-1.3.102 this is now cd dcc-dccproc-1.3.116

From: at: 2009-11-11 16:17:12

Please, someone, post the quota.txt file here, the website is no longer available

From: at: 2009-11-15 08:57:08

Hope, that helps:

 

#!/usr/bin/perl -w

# Author <jps@tntmax.com>
#
# This script assumes that virtual_mailbox_base in defined
# in postfix's main.cf file. This directory is assumed to contain
# directories which themselves contain your virtual user's maildirs.
# For example:
#
# -----------/
#            |
#            |
#    home/vmail/domains/
#        |          |
#        |          |
#  example.com/  foo.com/
#                   |
#                   |
#           -----------------
#           |       |       |
#           |       |       |
#         user1/   user2/  user3/
#                           |
#                           |
#                        maildirsize
#

use strict;

my $POSTFIX_CF = "/etc/postfix/main.cf";
my $MAILPROG = "/usr/sbin/sendmail -t";
my $WARNPERCENT = 80;
my @POSTMASTERS = ('postmaster@domain.tld');
my $CONAME = 'My Company';
my $COADDR = 'postmaster@domain.tld';
my $SUADDR = 'postmaster@domain.tld';
my $MAIL_REPORT = 1;
my $MAIL_WARNING = 1;

#get virtual mailbox base from postfix config
open(PCF, "< $POSTFIX_CF") or die $!;
my $mboxBase;
while (<PCF>) {
   next unless /virtual_mailbox_base\s*=\s*(.*)\s*/;
   $mboxBase = $1;
}
close(PCF);

#assume one level of subdirectories for domain names
my @domains;
opendir(DIR, $mboxBase) or die $!;
while (defined(my $name = readdir(DIR))) {
   next if $name =~ /^\.\.?$/;        #skip '.' and '..'
   next unless (-d "$mboxBase/$name");
   push(@domains, $name);
}
closedir(DIR);
#iterate through domains for username/maildirsize files
my @users;
chdir($mboxBase);
foreach my $domain (@domains) {
        opendir(DIR, $domain) or die $!;
        while (defined(my $name = readdir(DIR))) {
           next if $name =~ /^\.\.?$/;        #skip '.' and '..'
           next unless (-d "$domain/$name");
      push(@users, {"$name\@$domain" => "$mboxBase/$domain/$name"});
        }
}
closedir(DIR);

#get user quotas and percent used
my (%lusers, $report);
foreach my $href (@users) {
   foreach my $user (keys %$href) {
      my $quotafile = "$href->{$user}/maildirsize";
      next unless (-f $quotafile);
      open(QF, "< $quotafile") or die $!;
      my ($firstln, $quota, $used);
      while (<QF>) {
         my $line = $_;
              if (! $firstln) {
                 $firstln = 1;
                 die "Error: corrupt quotafile $quotafile"
                    unless ($line =~ /^(\d+)S/);
                 $quota = $1;
            last if (! $quota);
            next;
         }
         die "Error: corrupt quotafile $quotafile"
            unless ($line =~ /\s*(-?\d+)/);
         $used += $1;
      }
      close(QF);
      next if (! $used);
      my $percent = int($used / $quota * 100);
      $lusers{$user} = $percent unless not $percent;
   }
}

#send a report to the postmasters
if ($MAIL_REPORT) {
   open(MAIL, "| $MAILPROG");
   select(MAIL);
   map {print "To: $_\n"} @POSTMASTERS;
   print "From: $COADDR\n";
   print "Subject: Daily Quota Report.\n";
   print "DAILY QUOTA REPORT:\n\n";
   print "----------------------------------------------\n";
   print "| % USAGE |            ACCOUNT NAME          |\n";
   print "----------------------------------------------\n";
   foreach my $luser ( sort { $lusers{$b} <=> $lusers{$a} } keys %lusers ) {
      printf("|   %3d   | %32s |\n", $lusers{$luser}, $luser);
      print "---------------------------------------------\n";
   }
        print "\n--\n";
        print "$CONAME\n";
        close(MAIL);
}

#email a warning to people over quota
if ($MAIL_WARNING) {
        foreach my $luser (keys (%lusers)) {
           next unless $lusers{$luser} >= $WARNPERCENT;       # skip those under quota
           open(MAIL, "| $MAILPROG");
           select(MAIL);
           print "To: $luser\n";
      map {print "BCC: $_\n"} @POSTMASTERS;
           print "From: $SUADDR\n";
           print "Subject: WARNING: Your mailbox is $lusers{$luser}% full.\n";
           print "Reply-to: $SUADDR\n";
           print "Your mailbox: $luser is $lusers{$luser}% full.\n\n";
           print "Once your e-mail box has exceeded your monthly storage quota\n";
      print "your monthly billing will be automatically adjusted.\n";
      print "Please consider deleting e-mail and emptying your trash folder to clear some space.\n\n";
           print "Contact <$SUADDR> for further assistance.\n\n";
           print "Thank You.\n\n";
           print "--\n";
           print "$CONAME\n";
           close(MAIL);
        }
}

From: Den at: 2010-06-02 08:35:20

That helps a lot!

Thanks :)

Den

From: Anonymous at: 2009-10-21 07:45:34

Can sombody send me quota.txt or post some other link cose this isnt working

From: Marco at: 2009-10-01 12:36:19

The quata.txt page you mention is not there anymore (http://puuhis.net/vhcs/quota.txt).

By the way: this is a great tutorial!

Best regards.
Marco

From: timv at: 2010-11-22 08:00:08

Here is the info for quota.txt as the link in the document is dead.

 

11 Quota Exceedance Notifications

If you want to get notifications about all the email accounts that are over quota, then do this:

cd /usr/local/sbin/
nano quota.txt

#!/usr/bin/perl -w

# Author <jps@tntmax.com>
#
# This script assumes that virtual_mailbox_base in defined
# in postfix's main.cf file. This directory is assumed to contain
# directories which themselves contain your virtual user's maildirs.
# For example:
#
# -----------/
#            |
#            |
#    home/vmail/domains/
#        |          |
#        |          |
#  example.com/  foo.com/
#                   |
#                   |
#           -----------------
#           |       |       |
#           |       |       |
#         user1/   user2/  user3/
#                           |
#                           |
#                        maildirsize
#

use strict;

my $POSTFIX_CF = "/etc/postfix/main.cf";
my $MAILPROG = "/usr/sbin/sendmail -t";
my $WARNPERCENT = 80;
my @POSTMASTERS = ('postmaster@domain.tld');
my $CONAME = 'My Company';
my $COADDR = 'postmaster@domain.tld';
my $SUADDR = 'postmaster@domain.tld';
my $MAIL_REPORT = 1;
my $MAIL_WARNING = 1;

#get virtual mailbox base from postfix config
open(PCF, "< $POSTFIX_CF") or die $!;
my $mboxBase;
while (<PCF>) {
   next unless /virtual_mailbox_base\s*=\s*(.*)\s*/;
   $mboxBase = $1;
}
close(PCF);

#assume one level of subdirectories for domain names
my @domains;
opendir(DIR, $mboxBase) or die $!;
while (defined(my $name = readdir(DIR))) {
   next if $name =~ /^\.\.?$/;        #skip '.' and '..'
   next unless (-d "$mboxBase/$name");
   push(@domains, $name);
}
closedir(DIR);
#iterate through domains for username/maildirsize files
my @users;
chdir($mboxBase);
foreach my $domain (@domains) {
        opendir(DIR, $domain) or die $!;
        while (defined(my $name = readdir(DIR))) {
           next if $name =~ /^\.\.?$/;        #skip '.' and '..'
           next unless (-d "$domain/$name");
      push(@users, {"$name\@$domain" => "$mboxBase/$domain/$name"});
        }
}
closedir(DIR);

#get user quotas and percent used
my (%lusers, $report);
foreach my $href (@users) {
   foreach my $user (keys %$href) {
      my $quotafile = "$href->{$user}/maildirsize";
      next unless (-f $quotafile);
      open(QF, "< $quotafile") or die $!;
      my ($firstln, $quota, $used);
      while (<QF>) {
         my $line = $_;
              if (! $firstln) {
                 $firstln = 1;
                 die "Error: corrupt quotafile $quotafile"
                    unless ($line =~ /^(\d+)S/);
                 $quota = $1;
            last if (! $quota);
            next;
         }
         die "Error: corrupt quotafile $quotafile"
            unless ($line =~ /\s*(-?\d+)/);
         $used += $1;
      }
      close(QF);
      next if (! $used);
      my $percent = int($used / $quota * 100);
      $lusers{$user} = $percent unless not $percent;
   }
}

#send a report to the postmasters
if ($MAIL_REPORT) {
   open(MAIL, "| $MAILPROG");
   select(MAIL);
   map {print "To: $_\n"} @POSTMASTERS;
   print "From: $COADDR\n";
   print "Subject: Daily Quota Report.\n";
   print "DAILY QUOTA REPORT:\n\n";
   print "----------------------------------------------\n";
   print "| % USAGE |            ACCOUNT NAME          |\n";
   print "----------------------------------------------\n";
   foreach my $luser ( sort { $lusers{$b} <=> $lusers{$a} } keys %lusers ) {
      printf("|   %3d   | %32s |\n", $lusers{$luser}, $luser);
      print "---------------------------------------------\n";
   }
        print "\n--\n";
        print "$CONAME\n";
        close(MAIL);
}

#email a warning to people over quota
if ($MAIL_WARNING) {
        foreach my $luser (keys (%lusers)) {
           next unless $lusers{$luser} >= $WARNPERCENT;       # skip those under quota
           open(MAIL, "| $MAILPROG");
           select(MAIL);
           print "To: $luser\n";
      map {print "BCC: $_\n"} @POSTMASTERS;
           print "From: $SUADDR\n";
           print "Subject: WARNING: Your mailbox is $lusers{$luser}% full.\n";
           print "Reply-to: $SUADDR\n";
           print "Your mailbox: $luser is $lusers{$luser}% full.\n\n";
           print "Once your e-mail box has exceeded your monthly storage quota\n";
      print "your monthly billing will be automatically adjusted.\n";
      print "Please consider deleting e-mail and emptying your trash folder to clear some space.\n\n";
           print "Contact <$SUADDR> for further assistance.\n\n";
           print "Thank You.\n\n";
           print "--\n";
           print "$CONAME\n";
           close(MAIL);
        }
}
 

From: LightVision at: 2011-01-26 04:03:45

Those who are using your tutorial with copy and paste will stuck with vim and the certainly woul'nt know how to use it.

Default editor should be left as it is, in Debian: nano; advanced users would know how to change it anyway.

Besides the fact that I alway use dpkg -P vim-tiny vim-common tasksel tasksel-data and other few packages which are never used in a server.


In Debian Lenny 5.0.3 $pax='pax'; is enabled by default so it isn't necesary to include in /etc/amavis/conf.d/50-user


Two questions:

-For what is the cron? Ok, update database but with what and for what?

-How clamav update it's virus database ?


Thank You

From: Anonymous at: 2009-05-01 07:24:00

Hi, is it possible to put more than 1 address in field "destination" of  forwardings table? it doesn't seem to work. Can you help me?

 Very good work! thk

 

 

From: Anonymous at: 2009-09-15 07:43:25

You don't add several to the destination, you just insert a second row with all fields the same, but the destination differing.

 

from/to:

test@test.com/destination@test.com

test@test.com/otherdestination@test.com

 

If, for example, only the destination differs, you still insert a row for each unique forwarding.

 

Tim

From: Karolis Tamutis at: 2010-01-04 20:35:33

Please save yourself some frustration and know that passwords encrypted with crypt are salted, up to 8 characters long.

You may enter 9+ char password into PMA which would discard everything after 8th char, this can lead to some weird scenarions, like users being able to authenticate with other users passwords (which match up to 8 first chars).

In short: be aware of the 8 char limit, users with MySQL setup passwords such as 123456781 and 123456782 will be able to authenticate with either password.

From: at: 2010-02-01 14:42:16

If I setup as a local user an email like user@gmail.com then when I want to send an email to externaluser@gmail.com, postfix will try to send that email locally, because match gmail.com in mail_domains and it think that that is an internal email...

 Any idea how to solve this problem?

 

Thanks

MiK

From: Anonymous2 at: 2010-02-24 23:39:56

Hey!

When I try to send an email from yahoo/google to the email account which I inserted into the databases, the email isn't delivered.

The mail from yahoo says:

 test@mydomain.com: unknown user: test


From: tomiC at: 2010-09-30 14:57:03

When i try to start postfix /etc/init.d/postfix restart i get the following message in the mail.log

fatal: /etc/postfix/master.cf: line 83: missing "transport type" field

What's the problem?

regards

From: Pete at: 2011-03-08 01:46:54

This is a superb tutorial, I learnt so much from it, and best of all, it works!  Thanks very much for all your time and effort.

From: at: 2009-04-10 05:05:40

If you try to apt-upgrade the system, it will report that postfix and postfix-mysql should be upgraded too. To prevent this from happening you could run the following command (become root first):

 echo postfix hold | dpkg --set-selections && echo postfix-mysql hold | dpkg --set-selections

 This should prevent apt from upgrading the package (with upgrade or dist-upgrade).

 To restore it (when actually a new version comes out) use:

  echo postfix install | dpkg --set-selections && echo postfix-mysql install | dpkg --set-selections

 

From: Cory LYnch at: 2009-11-11 12:15:42

ok so after following this tutorial completely for about an hour or so i finished went and restarted apache noticed the squirrellmail page wasnt loading or any of my other previous functional websites.

the errors apache are spiting at me are:

 [Wed Nov 11 12:01:55 2009] [info] mod_fcgid: Process manager 2031 started
[Wed Nov 11 12:01:55 2009] [error] mod_log_sql: insufficient configuration info to establish database link
[Wed Nov 11 12:01:55 2009] [error] mod_log_sql: child spawned but unable to open database link
[Wed Nov 11 12:01:55 2009] [error] mod_log_sql: insufficient configuration info to establish database link
[Wed Nov 11 12:01:55 2009] [error] mod_log_sql: child spawned but unable to open database link
[Wed Nov 11 12:01:55 2009] [error] mod_log_sql: insufficient configuration info to establish database link
[Wed Nov 11 12:01:55 2009] [error] mod_log_sql: child spawned but unable to open database link
[Wed Nov 11 12:01:55 2009] [error] mod_log_sql: insufficient configuration info to establish database link
[Wed Nov 11 12:01:55 2009] [error] mod_log_sql: child spawned but unable to open database link
[Wed Nov 11 12:01:55 2009] [notice] Apache/2.2.9 (Debian) mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
[Wed Nov 11 12:01:55 2009] [info] Server built: Jul 14 2009 20:03:28
[Wed Nov 11 12:01:55 2009] [debug] prefork.c(1032): AcceptMutex: sysvsem (default: sysvsem)
[Wed Nov 11 12:01:55 2009] [error] mod_log_sql: insufficient configuration info to establish database link
[Wed Nov 11 12:01:55 2009] [error] mod_log_sql: child spawned but unable to open database link

if you can help i would greatly appreciate it.

From: admin at: 2009-04-08 08:42:04

You probably made a syntax error when you edited the change_sqlpass configuration file:

http://www.howtoforge.com/forums/showthread.php?t=32673&highlight=syntax+error+squirrelmail

From: at: 2009-09-13 11:16:38

The mistake that I made was here:

$password_update_queries = array('UPDATE users SET password = %4 WHERE email = "%1"');

 

The line in the default config file is split over several lines:

 $password_update_queries = array(

                  'UPDATE users SET password = %4 WHERE email = "%1"'

                   );

 

So blindly copying and pasting resulted in me having a duplicate `);`.

From: Anonymous at: 2009-04-07 23:26:54

I only ran into two small problems:

Problem: postfix/tlsmgr[31109]: warning: request to update table btree:/var/spool/postfix/smtpd_scache in non-postfix directory /var/spool/postfix

Solution: Change both smtp*_tls_session_cache_database in /etc/postfix/main.cf from "$queue_directory" to "$data_directory".

# mkdir /var/spool/postfix/smtp_scache

# mkdir /var/spool/postfix/smptd_scache

# chown -R postfix /var/spool/postfix/smtp_scache

# chown -R postfix /var/spool/postfix/smtpd_scache

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

 Problem: Blank page after squirrelmail login.

Solution: Well, it's not really a solution - more of a workaround.   Run /usr/sbin/squirrelmail-configure and remove the change_sqlpass plugin.  If someone discovers a real solution, please post it here.

From: Anonymous at: 2009-07-15 14:03:34

http://www.postfix.org/postconf.5.html#smtp_tls_session_cache_database

"As of version 2.5, Postfix no longer uses root privileges when opening this file. The file should now be stored under the Postfix-owned data_directory. As a migration aid, an attempt to open the file under a non-Postfix directory is redirected to the Postfix-owned data_directory, and a warning is logged."

I believe that /var/spool/postfix is not you data_directory.

From: A Happy Reader at: 2009-03-25 02:33:30

Hello! Your Guide is Great! i managed to put together a mail server! my only tiny problem is whit SquirrelMaill PW change feature. it says  "ERROR Could not make database connection"  So if you could plz help me out. I don't wana rush you its not so big problem :) And Tanks again.!   

From: at: 2009-07-01 11:47:07

Only 1 problem :

ERROR: Connection dropped by IMAP server.

From: hstoellinger at: 2009-11-17 12:03:54

Has anybody found a solution to this issue. The only thing I can think of regarding my own "walk" through this excellent tutorial is that this is my test system I am using a dynamic IP address established by my provider. Therefore I thought that using "localhost" as the FQDN might be appropriate. Is this assumption wrong? I do want to test everything before I go live on my production system.

Again, I don't remember ever going through a better tutorial than this one. Congratulations!

Any help would be greatly appreciated. As usual, I am pressed for time and the mailserver should go online within the coming two weeks.

Regards

H. Stoellinger

From: fulm at: 2009-12-18 13:16:32

someone has a solution to solve the problem?

From: mitja at: 2009-11-20 01:29:49

ERROR: Connection dropped by IMAP server.

 

I get the same problem... Any idea how to solve this? It seems i'm not the only one with the problem

From: Fejame at: 2010-04-27 18:15:30

ERROR: Connection dropped by IMAP server.

login squirrelmail??

 

From: Anonymous at: 2009-09-18 01:24:44

same problem

From: Anonymous at: 2009-08-29 06:57:28

Same problem here

From: Yogalu at: 2010-11-05 14:01:01

Well, i had the same problem as all you guys...

 I did some testing and log checking

 tail -f /var/log/mail.log &

 which kept giving me:

authdaemond: failed to connect to mysql server (server=localhost, userid=mail_admin): Access denied for user 'mail_admin'@'localhost' (using password: YES)

 So in the end (and with a little help from another page) i found out there was a 'SPACE' behind the password in the file  /etc/courier/authmysqlrc

So edit that file, make sure there is no space behind the password and restart the authdaemon

/etc/init.d/courier-authdaemon restart

And try again.

From: ifos at: 2010-07-15 05:32:47

maildirmake /home/vmail/example.com/sales

chown -hR vmail:vmail /home/vmail/example.com/sales

From: catchu at: 2011-04-26 16:50:25

tail -f /var/log/mail.log &

 I found:
failed to connect to mysql server (server=localhost, userid=mail_admin): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

 So I have to excute:
ln -s  /tmp/mysql.sock  /var/run/mysqld/mysqld.sock

But it still doesn't work.

Then:
maildirmake /home/vmail/example.com/sales
chown -hR vmail:vmail /home/vmail/example.com/sales


it works :)

 

THX to ifos & Yogalu.

 

From: Anonymous at: 2010-03-12 09:45:12

Hi,

thanks for this really great howto, I appreciate the work and knowledge given here.

I would like to add two notes:

ClamAV is, as all on-access virus scanners, very ressource intensive. After testing it on a general purpose webserver hosted on vps, I decided to remove it to have more ram for the apache processes.

The command:
postconf -e 'mydestination = server1.example.com, localhost, localhost.localdomain'
did not work in my case.  Yes, I have replaced "server1.example.com" with the correct FQDN. No mail got through postfix and mailboxes were not created, which triggered the Squirrelmail error "Connection dropped by IMAP server". I was able to fix this by altering the command to:
postconf -e 'mydestination = '
Sorry, I don't know why, maybe because of double clarifications of the hostname there and in the database. I use the hostname of the mailserver also in the virtual users database, to create email adresses for this domain. Now it's working.

Thanks again for the great work.

Best Regards
Anonymous

From: catchu at: 2011-04-27 15:12:46

 I couldn't receive mail too and found the following when ’tail -f /var/log/mail.log &‘

warning: do not list domain ltns.info in BOTH mydestination and virtual_mailbox_domains

 Then I modified /etc/postfix/main.cf as you mentioned.  It works.  :)

'mydestination = '

Thank you, and falko's great hwoto.

From: Niklas C Aden at: 2011-01-31 12:07:49

Hey, all is good!

Except one thing, when I try to enter the squirrelmail it just gives me a blank page.

I've checked the apache2 log file and the mail.log file without success, there's simply no error msg when I try to sign in :/
Tried it with 2 different accounts in 2 different domains, just to see what could cause it.

From: michael at: 2011-02-24 17:01:59

Amavis-ng won't scan mails in that configuration. At least not the current version ( amavisd-new-2.6.4 ) on debian squeeze.

As it only scans outgoing mails it needs to determine which domains are local. You need to edit the file /etc/amavis/conf.d/50-user and add the following lines (replacing your password off course):

 @lookup_sql_dsn = (
    ['DBI:mysql:database=mail;host=127.0.0.1;port=3306',
     'mail_admin',
     'mail_admin_password']);

$sql_select_policy = 'SELECT domain FROM domains WHERE CONCAT("@",domain) IN (%k)';


From: dynamike at: 2011-10-05 13:19:33

Hey,

first of all, thank you so much for this great tutorial. My mail infrastructure is up and running.

What I am wondering is how and which server-side filtering solution can be integrated to e.g. move the emails marked as SPAM etc. to specific folders.

Any help more than appreciated.

Cheers,

Dynamike