Now that you have a fully functional email service, you'll no doubt want to make some refinements to its configuration. Mac OS X Server offers numerous mail server enhancements through the Server Admin tool, as well as many that can be configured from the command line via the Terminal application. Setting mail quotasYou generally don't want your users to be able to accept emails of an unlimited size or to accumulate an excess amount of email in their inbox. Doing so would put a strain both on your server's bandwidth and on the disk space consumed by your mail service. You can control this through the use of quotas. Mac OS X Server offers two sets of quotas that you can define for your mail service: per-message size limits that control the maximum size of an individual message as it's received by your server, and per-mailbox size limits, which control the total size of any one user's mailbox. To limit mail size
You also want to limit the maximum size of any user's mailbox. There are two types of quotas to be applied here. The first is known as a soft quota, which is merely a quota warning a user that he or she is approaching (or even exceeding) their quota, but no mail is ever blocked for the user. The other type of quota is a hard quota. With hard quotas enabled, once the user reaches their maximum mailbox size, any future emails addressed to that user will be returned to the sender and will be undelivered. Generally soft quotas are preferred since it won't result in email being denied for a user, but if you're tight on disk space or have users who ignore the warnings, you'll want to use the hard quotas. To enable soft quotas
Setting mailbox quotasThe settings you just enabled apply to all users, but by default, users don't actually have a mailbox quota set. To set the quota for each account
Handling junk mail and virusesOne thing you'll want to do for your users is scan their email for spam or other unsolicited junk mail. Mac OS X Server includes SpamAssassin, an open source solution for doing just that. Although SpamAssassin provides a mechanism to scan messages by itself, Apple has chosen to scan mail using another open source solution: AMaViS (A Mail Virus Scanner) calls the SpamAssassin modules internally, simultaneously passing each message through ClamAV, an open source antivirus scanner, while scanning it for spam contentand it all happens automatically as soon as the server receives each message. To configure your mail server for spam and virus scanning
Scoring junk mailThere are a number of other customizations you can make on the last screen in the previous exercise. The most visible one is the Minimum junk mail score, which defaults to 5 hits. Every time a message is received by your server, it is assigned a score, based on how many spam tests were matched and the probability of each test indicating that the message is spam. If the score it receives is lower than 5, it's considered not spam (sometimes called ham). If the score is 5 or above, the message is tagged as spam. When this happens, the subject line has *** JUNK MAIL *** prepended to it, and some extra headers are added indicating the actual score and the tests that matched. You can, of course, change these options, but the defaults are good ones to stick with until you are more familiar with the operation of the junk mail scanner. Checking email for spam is a tricky problem. On one hand, nobody likes to receive spam. An even worse problem, however, is when a legitimate message is tagged as spam. This is known as a false positive, and can occur when you have your minimum junk mail score set too low. The default of 5 is a good starting point, but if you discover too many false positives, you may want to adjust this number to be higher. Junk mail trainingOne of the best ways to check for spam is using a technology called Bayesian Filters. These filters examine the contents of the message for certain patterns common to spam messages. This filtering process is included as part of SpamAssassin, but first must be trained. If you already have some folders of mail that contain example messages of both spam and non-spam, save them out to two directories, one containing only spam messages, the other containing only non-spam messages. You can perform your initial spam training using these commands in Mac OS X 10.4.010.4.3 from the Terminal on your server or a remote ssh connection: sudo /bin/rm -rf /private/var/amavis/ .spamassassin sudo ln -s /private/var/clamav/ .spamassassin /private/var/amavis/ .spamassassin sudo -s su - clamav -c "sa-learn --spam --showdots /Path/To/JunkMail/Folder su - clamav -c "sa-learn --ham --showdots /Path/To/NonJunkMail/Folder You'll also want to continually update the spam training. As messages arrive, the Bayesian database is continually updated. Occasionally, you will receive a message that was mis-tagged as spam or not-spam. When this happens, you'll want to provide a place for users to submit their own samples of messages that are spam or are not spam. For this, create two accounts with special names: junkmail and notjunkmail. The mailboxes of these accounts are in place for users to bounce or redirect appropriate messages to, and are scanned once a night for inclusion in the Bayesian database. To create spam accounts
Tip
Offering mailing listsMailing lists, which are sometimes called listservs, offer a convenient way for people inside or outside of your organization to form a group identified by one email address. Mac OS X Server provides an open source solution called Mailman, with features such as message archiving, private lists, moderated lists, commands sent through email, and much more. You can manage mailing lists through the Server Admin tool, or users can manage their own lists with a convenient Web interface. To enable mailing lists
To create mailing lists
To set options for your list through the Web interface
Tips
Storing mailIn the days of older mail systems, mail was simply stored in one file per user. Although this was much simpler to deal with, it was also much slower, particularly for large mailboxes. To alleviate this problem, Cyrus, the mail storage mechanism used by Mac OS X Server, splits the mail up into a large number of files, with an associated database for each user, allowing for faster searching and quicker retrieval of any given message. To locate the Cyrus mail store
Backing up mailFigure 8.35 shows a typical mail server, where the database of mailboxes is stored in /var/imap, and each mailbox is located in /var/spool/imap. If you have many users, you may also be storing mail in other locations, which will be shown in the window at the bottom. Figure 8.35. Server Admin shows where your mail databases are stored. This screen also has a repair button to fix your mail databases.Numerous configuration and database files are stored in the following locations:
As with any important data, your mail server should be backed up. Unfortunately, since mail relies so heavily on databases, the mail service should be shut down while the backup is taking place. This avoids problems that might arise from a mailbox being modified after the database for that mailbox has been saved but before the actual mail data has been backed up. The downside to shutting down your mail server when you make backups is that users with IMAP connections will get disconnected. This inconvenience will have to be weighed against the need for accurate regular backups, and, depending on the types of users you support, could dictate the frequency of your mail server backups. Mac OS X Server has no built-in GUI for performing mail server backups. You'll want to create a series of shell scripts that can be automatically run by cron to automate the task of doing mail server backups. To prepare your system for mail backups, you must first create some directories that will store the backups. Execute the following commands: mkdir -p /var/backupmail/tmp chown root:wheel /var/backupmail/tmp chmod 700 /var/backupmail Next, you need to actually save your mail server data in a backup. These commands should be placed in a script, which could be put in /private/etc/periodic/daily so that it's run automatically every day: /usr/sbin/serveradmin stop mail rsync -exclude=socket -delete -a /var/imap/ /var/backupmail/ tmp/varimap rsync -delete -a /var/spool/imap/ var/backupmail/tmp/varspoolimap rsync -delete -a /etc/postfix/ /var/backupmail/tmp/etcpostfix rsync -delete -a /etc/mail/ /var/ backupmail/tmp/etc/postfix rsync -delete -a /var/amavis/ /var/backupmail/tmp/varamavis rsync -delete -a /var/clamav/ /var/backupmail/tmp/varclamav /usr/sbin/serveradmin start mail tar -C /var/backupmail -zcpf /var/ backupmail/`date +%a`.tar.gz tmp By using rsync, you're only updating copies of files that have changed, thus minimizing the downtime of your mail service. The tar command at the end will compress that day's backup into a file named Mon.tar.gz, Tue.tar.gz, and so on for each day of the week. Consult the date man page for other options you could use. If you need to restore files from a particular backup, execute these commands: mkdir /var/backupmail/restore cd /var/backupmail/restore sudo tar -zxpf /var/backupmail/ DAY.tar.gz Once the archive is expanded, you can copy any missing or corrupted files to their appropriate location.
Fixing mailbox corruptionShould you run into problems with your mail server, one of the most likely culprits is mail database corruption. Before you restore a corrupted database from your backups, you should first try repairing the existing database. To fix common database corruption problems
|