Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (Mandriva 2009.0 i386) - Page 4
10 Install Razor, Pyzor And DCC And Configure SpamAssassin
Razor, Pyzor and DCC are spamfilters that use a collaborative filtering network. To install Razor, Pyzor, and DCC, run
urpmi perl-Razor-Agent pyzor dcc
Then initialize Razor and Pyzor:
chmod -R a+rX /usr/share/doc/pyzor /usr/bin/pyzor /usr/bin/pyzord
Now we have to tell SpamAssassin to use these three programs. Edit /etc/mail/spamassassin/local.cf so that it looks like this:
cp /etc/mail/spamassassin/local.cf /etc/mail/spamassassin/local.cf_orig
Then we must enable the DCC plugin in SpamAssassin. Open /etc/mail/spamassassin/v310.pre and uncomment the loadplugin Mail::SpamAssassin::Plugin::DCC line:
You can check your SpamAssassin configuration by executing:
It shouldn't show any errors.
Now we update our SpamAssassin rulesets as follows:
We create a cron job so that the rulesets will be updated regularly. Run
to open the cron job editor. Create the following cron job:
This will update the rulesets every second day at 4.23h.
11 Quota Exceedance Notifications
If you want to get notifications about all the email accounts that are over quota, then do this:
Open /usr/local/sbin/quota_notify and edit the variables at the top. Further down in the file (towards the end) there are two lines where you should add a % sign:
to create a cron job for that script:
12 Test Postfix
To see if Postfix is ready for SMTP-AUTH and TLS, run
telnet localhost 25
After you have established the connection to your Postfix mail server type
If you see the lines
250-AUTH PLAIN LOGIN
everything is fine.
[root@server1 sbin]# telnet localhost 25
to return to the system's shell.
13 Populate The Database And Test
To populate the database you can use the MySQL shell:
mysql -u root -p
At least you have to create entries in the tables domains and users:
INSERT INTO `domains` (`domain`) VALUES ('example.com');
(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 ('firstname.lastname@example.org', 'email@example.com');
To leave the MySQL shell, type
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:
The transport table can have entries like these:
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
after you have made your changes in the transport table.
14 Send A Welcome Email For Creating Maildir
When you create a new email account and try to fetch emails from it (with POP3/IMAP) you will probably get error messages saying that the Maildir doesn't exist. The Maildir is created automatically when the first email arrives for the new account. Therefore it's a good idea to send a welcome email to a new account. For example, to send a welcome email to firstname.lastname@example.org, we do this:
You will be prompted for the subject. Type in the subject (e.g. Welcome), then press ENTER, and in the next line type your message. When the message is finished, press ENTER again so that you are in a new line, then press CTRL+D to finish the mail:
[root@server1 mail]# mailx email@example.com