Zimbra and Logwatch, The Whole Story

I used to run my own, cobbled-together mail server on Gentoo. It was pretty cool, and I learned a lot, but it was also a lot of work. That setup was borne out of trying to extend my efforts of running a public email server for this domain back when I had DSL (and they didn’t care that I did such things), and due to the fact that I wanted to retain control over my mail messages. Since switching from Gentoo to Ubuntu, I wanted to continue to do this. However, Ubuntu is less flexible when it comes to setting up a bunch of interleaving packages, so I went looking for an alternative arrangement.

I had used OpenGroupware, and then Scalix, for my church, but the primary motivator there was Outlook compatibility, which I couldn’t care less about, personally. Then I discovered Zimbra. It’s pretty amazing stuff, all things considered. They’ve taken a lot of fiddly open source products, gotten them to play together nicely, and then put a wonderful front end over the whole thing. (That they offer this stuff for free amazes me. I hope they don’t pull another open-source switcheroo, and take it completely commercial some day.)

One of the things I like to do with my servers is put logwatch on them. I don’t actually read the log every day, but I like getting them each day, to make sure the server’s still alive, and I occasionally check them for big problems. However, getting logwatch to work on a Zimbra server can be a bit of a pain. See, Ubuntu’s logwatch package relies on their package of postfix. That’s fine; of course logwatch would need some sort of MTA. However, it can’t recognize that Zimbra has already installed one. So there are a couple of configuration tweaks you need to do to make it work. For work and for home (and for various reaons), I’ve reinstalled Zimbra several times, and I have to keep re-learning the way all of these things interact with one another, so I decided to make myself a note here.

First of all, to even install the logwatch package, your system has to think that there’s a mail transfer agent (MTA) on the system. To fool it, you can use the mta-dummy package. (I see that a new version is now being hosted at GitHub. The README file has an unfortunate snark in it. Does he really think that the people packaging Zimbra don’t know how to make a .deb?)

Now that logwatch is installed, you still need to point it toward an MTA. You can do this in either of 2 ways. Firstly, logwatch has a config file buried in the filesystem as /usr/share/logwatch/default.conf/logwatch.conf. In that file, you can change the “mailer” variable:

mailer = "/opt/zimbra/postfix/sbin/sendmail -t"

However, I don’t like changing config files outside of /etc (preferably in /etc/default). So, secondly, you could inform the system as a whole to point any program which may try emailing something to Zimbra’s MTA, using the “standard” Ubuntu way of the `update-alternatives’ command:

update-alternatives --install /usr/lib/sendmail mta-sendmail /opt/zimbra/postfix/sbin/sendmail 25

You can test local mail delivery with the `mail’ command, which you can install with the “bsd-mailx”* package. I like to just run `mail root < /etc/hosts’. However, you still won’t be able to test your end-to-end email delivery.

System mail, like that generated by `mailx’, will tend to be delivered to “root@localhost.localdomain”. Zimbra won’t recognize that this is meant for your “localdomain” domain. To fix this, again you have 2 choices. First, you may want to use”zmprov” to mess about with postfix’s “mydestination” variable:

zmprov mcf zimbraMtaMyDestination foo, bar, baz

(I suppose you could fix this my monkeying around with Zimbra’s postfix’s main.cf file, but Zimbra store it’s configuration in a database (somewhere; I’ve never tried to figure out where) and generates those types of config files, so manual edits will probably be lost in due time.)

The second option is to create a whole new domain within the Zimbra administration console, named for the local machine. In my case, my main domain is “starfleet.mil”, so I have a secondary domain called “excelsior.starfleet.mil”. In this domain, I have one account, “root”, and it forwards to my main account in my hosted domain.

So, to recap:

  1. Install a mta-dummy package
  2. Install the logwatch package
  3. Use `update-alternatives’ to point to Zimbra’s sendmail
  4. Create another Zimbra domain for local mail

* There is another “mail” command you can install on Ubuntu called “heirloom-mailx”. Unfortunately, this package is compiled with a hardcoded path to sendmail as “/usr/lib/sendmail”, instead of the update-alternatives linked “/usr/sbin/sendmail”. You can override this by using an environment variable for “sendmail”, e.g.:

sendmail=/usr/sbin/sendmail mailx root < /etc/hosts

P.S. I find the “nullmailer” package very useful on other local machines, to get administrative email over to the Zimbra machine.

  • You may use these HTML tags: <a> <abbr> <acronym> <b> <blockquote> <cite> <code> <del> <em> <i> <q> <strike> <strong>

  • Comment Feed for this Post
Go to Top