Virtual Users And Domains With Postfix, Courier And MySQL (Ubuntu 6.10 Edgy Eft) - Page 6

13 Populate The Database And Test

To populate the database you can use the MySQL shell:

mysql -u root -p
USE mail;

At least you have to create entries in the tables domains and users:

INSERT INTO `domains` (`domain`) VALUES ('example.com');
INSERT INTO `users` (`email`, `password`, `quota`) VALUES ('sales@example.com', ENCRYPT('secret'), 10485760);

(Please take care you use the ENCRYPT syntax in the second INSERT statement in order to encrypt the password!)

If you want to make entries in the other two tables, that would look like this:

INSERT INTO `forwardings` (`source`, `destination`) VALUES ('info@example.com', 'sales@example.com');
INSERT INTO `transport` (`domain`, `transport`) VALUES ('example.com', 'smtp:mail.example.com');

To leave the MySQL shell, type

quit;

For most people it is easier if they have a graphical front-end to MySQL; therefore you can also use phpMyAdmin (in this example under http://192.168.0.100/phpmyadmin/ or http://server1.example.com/phpmyadmin/) to administrate the mail database. Again, when you create a user, go sure that you use the ENCRYPT function to encrypt the password:

I do not think I have to explain the domains and users table further.

The forwardings table can have entries like the following:

source destination  
info@example.com sales@example.com Redirects emails for info@example.com to sales@example.com
@example.com thomas@example.com Creates a Catch-All account for thomas@example.com. All emails to example.com will arrive at thomas@example.com, except those that exist in the users table (i.e., if sales@example.com exists in the users table, mails to sales@example.com will still arrive at sales@example.com).
@example.com @anotherdomain.tld This redirects all emails to example.com to the same user at anotherdomain.tld. E.g., emails to thomas@example.com will be forwarded to thomas@anotherdomain.tld.
info@example.com sales@example.com, billing@anotherdomain.tld Forward emails for info@example.com to two or more email addresses. All listed email addresses under destination receive a copy of the email.

The transport table can have entries like these:

domain transport  
example.com : Delivers emails for example.com locally. This is as if this record would not exist in this table at all.
example.com smtp:mail.anotherdomain.tld Delivers all emails for example.com via smtp to the server mail.anotherdomain.com.
example.com smtp:mail.anotherdomain.tld:2025 Delivers all emails for example.com via smtp to the server mail.anotherdomain.com, but on port 2025, not 25 which is the default port for smtp.
example.com

smtp:[1.2.3.4]
smtp:[1.2.3.4]:2025
smtp:[mail.anotherdomain.tld]

The square brackets prevent Postfix from doing lookups of the MX DNS record for the address in square brackets. Makes sense for IP addresses.
.example.com smtp:mail.anotherdomain.tld Mail for any subdomain of example.com is delivered to mail.anotherdomain.tld.
* smtp:mail.anotherdomain.tld All emails are delivered to mail.anotherdomain.tld.
joe@example.com smtp:mail.anotherdomain.tld Emails for joe@example.com are delivered to mail.anotherdomain.tld.

See

man transport

for more details.

Please keep in mind that the order of entries in the transport table is important! The entries will be followed from the top to the bottom.

Important: Postfix uses a caching mechanism for the transports, therefore it might take a while until you changes in the transport table take effect. If you want them to take effect immediately, run

postfix reload

after you have made your changes in the transport table.

 

14 References

 

15 Links

Share this page:

5 Comment(s)

Add comment

Comments

From: at: 2007-05-10 09:06:55

page 1

debian etch uses a different postfix version so you ll find the patch for this version on the blow url

http://vda.sourceforge.net/VDA/postfix-2.3.8-vda.patch.gz

for compiling this newer postfix version you need to get a few more libraries

apt-get install lsb-release libcdb-dev

page 3

/etc/default/saslauthd

change

START=no

into

START=yes

and add these lines to the end of the file (PARAMS has been changed to OPTIONS)

OPTIONS="-m /var/spool/postfix/var/run/saslauthd -r"
PIDFILE="/var/spool/postfix/var/run/${NAME}/saslauthd.pid"

close file and run

dpkg-statoverride --add root sasl 710 /var/spool/postfix/var/run/saslauthd
adduser postfix sasl

page 4

NotifyClamd /etc/clamav/clamd.conf
already ok

From: at: 2007-10-24 00:48:02

Followed Falko's The Perfect Server - Ubuntu Gutsy Gibbon (Ubuntu 7.10) tutorial (which is excellent and very timely), but for postfix and apache, substituted the procedures in here.

The only part that did not work at all was the Postfix patch for quotas. Gutsy installed Postfix-2.4.5; I found what may be the updated quota patch here:

http://vda.sourceforge.net/VDA/postfix-2.4.5-vda-ng.patch.gz

but was unable to build the .deb package; there were some issues with libdb4.3-dev among others. If someone would care to elaborate, it would be a great service.

I also skipped the spam/virus portions since I already use a hosted service for this.

Postfix / courier seem to be up and running as described.

 -- DrJohn

Some other quick notes on the installs:

 2. Install Postfix, Courier, Saslauthd, MySQL, phpMyAdmin

:
:

To install Postfix, Courier, Saslauthd, MySQL, and phpMyAdmin, we simply run:

<changed libsasl2 to libsasl2-2>


apt-get install postfix postfix-mysql postfix-doc mysql-client mysql-server courier-authdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl postfix-tls libsasl2-2 libsasl2-modules libsasl2-modules-sql sasl2-bin libpam-mysql openssl phpmyadmin apache2 libapache2-mod-php5 php5 php5-mysql


extra qestion appears re phpMyAdmin:


ââââââââââââââââââââââââ⤠Configuring phpmyadmin âââââââââââââââââââââââââ
   â phpMyAdmin supports any web server that PHP does, but this automatic   â
   â configuration process only supports Apache.                            â
   â                                                                        â
   â Web server to reconfigure automatically:                               â
   â                                                                        â
   â    [*] apache2                                                         â
   â    [ ] apache                                                          â
   â    [ ] apache-ssl                                                      â
   â    [ ] apache-perl                                                     â
   â                                                                        â
   â                                                                        â
   â                                 <Ok>                                   â
   â                                                                        â
   ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ






create the SSL certificate that is needed for TLS:


<questions asked are different than the tutorial>

root@myserver/etc/postfix# openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 365 -x509
Generating a 2048 bit RSA private key
................+++
...........................+++
writing new private key to 'smtpd.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:MyState
Locality Name (eg, city) []:MyCity
Organization Name (eg, company) [Internet Widgits Pty Ltd]:MyCompany
Organizational Unit Name (eg, section) []:.
Common Name (eg, YOUR name) []:Postmaster
Email Address []:info@mydomain.com
root@myserver/etc/postfix#

 

From: at: 2007-06-22 02:17:33

I was having trouble getting it to authenticate so turned on verbose logging for saslauthd. It revealed that the realm was not getting appended to the user and hence the sql select was returning zero records.
The bottom of /etc/defaults/saslauthd shows an "OPTIONS" line rather than "PARAMS". Checking the documentation for my version of saslauthd confirmed this.

Hence for Feisty 7.04 change:
  PARAMS="-m /var/spool/postfix/var/run/saslauthd -r"
to:
  OPTIONS="-m /var/spool/postfix/var/run/saslauthd -r"

From: at: 2007-08-09 12:20:27

With Feisty 7.04 the dcc-client fails with unsatisfied dependencies.

The following line seems to work:

apt-get install dcc-common=1.2.74-2 dcc-client=1.2.74-2

Also the postfix patch for quota may not be needed  under Feisty.

From: at: 2007-08-09 12:23:09

This howto is an excellent tutorial. It has rocksolid step by step instructions, easy to follow and seems to be mistake free in its instructions.

The difference between using this for Edgy and Feisty is very little (except for the quota patch and dcc-client).

Many thanks for  your time and effort.