Smail - the lighter mail server

Smail - the lighter mail server


When most people install a free software mail transport agent (MTA) they plumb for Postfix, Exim, qmail or Sendmail. Whilst these are all fine, they can be a little over the top for some smaller systems or systems where all you need is some kind of local MTA functionality. In these cases many people will install their favourite MTA anyway -- but there are more lightweight alternatives. Here I look at one of them: Smail.

Before I go any further I should clarify -- for those who don't already know -- that Smail is not a mail client. It won't do what Thunderbird, Evolution, Kmail and Mutt do. It delivers email for those programs. It also does not provide POP3 or IMAP services. Like most MTAs it performs a single core task; it routes email from one place to another.

Old kid on the block

Smail is no young whipper-snapper. It pre-dates Exim, qmail and Postfix -- in fact Exim owes a lot to Smail for its existence. There's some confusion as to whether Smail or Sendmail was developed first but certainly they seemed to have arrived around the same time. Smail has been at the same major version (3) since 1994. It's by no means immature software.

Why and where

Smail is simple, clean and efficient. Although it is as secure as pretty much most of its larger cousins (it's been the subject of just one security advisory), it has arguably one of the least cumbersome configuration set-ups around. Its small size and simple configuration make it a great replacement for the bigger MTAs -- especially Sendmail -- in situations where you just don't have the time/energy/patience to get involved with configuring an MTA.

Smail's small size and simple configuration are ideal where you don't have the time/energy/patience for a large MTA

Smail would be ideal for any situation where complex routing, filters and features (virtual users etc.) are not required. I've used it on many a desktop or laptop system where I've been developing projects that require a local MTA. I've also deployed it on smaller servers that do not provide SMTP to their respective clients. In these cases I needed something to forward locally-produced error messages, cron-job feedback and backup notifications to a remote address (mine). These servers had smaller resources than I would usually use for Exim (my preferred MTA) and so Smail became my "small scale" MTA.

Set-up

Smail is more than likely a package on your system. On a Debian system it's just an apt-get install smail away. If you are running testing or unstable you'll not find a package for it -- I assume that's because there's no later version that the stable one. In that case just download it from Debian's website. Finally, Smail can operate in a number of "modes", one of these uses UUCP to a smarthost: if you want to use it that way you need to ensure uucp is installed as well.

Once installed you need to configure it. This is done via the smailconfig utility (on Debian this is run post-installation for you). Configuration is just a series of half a dozen or so basic questions and you are done. If you are running Smail on a machine which will route all non-local mail to another SMTP server (e.g. a ISP or your company's outgoing MTA), you will probably want to run it as an "Internet site" and (when asked) specify it to only accept connections from the localhost address (127.0.0.1). The smarthost in these cases will be your usual SMTP mail server and usually you want to have Smail deliver any mail it cannot find a route for to the smarthost. These are the default options anyway so you'll probably find yourself hitting enter a few times -- making sure you read what you are agreeing to first though! Next you give it a local user to deliver postmaster's and root's mail to. Finally, you are asked whether to insert a line in /etc/inetd.conf to run Smail when needed or to start it as a daemon. I usually go with the (default) former.

In all the times I've installed Smail, set-up has taken no more than three minutes

When all the questions have been answered you confirm what you've given and the configuration is done. In all the times I've done this, it has taken no more than three minutes, which included looking up the smarthost address. After the config files are written you are given the option to send some test messages. Unless the local machine's fully qualified domain name (FQDN) can be routed to publicly, I would suggest you do not have Smail test offsite delivery. You can do this later by sending a message to a mail account of your choosing. I prefer to just have it send a local test message to see if routing is configured correctly.

Using it

To use Smail you call it within a shell or a script. smail username@domain.com is probably the simplest form and will allow you to enter a message on the following lines to deliver to the address provided. That message will probably need to include certain headers (Subject: test message ) to make it more readable to the recipient. Like all good MTAs, Smail will add the required headers if you don't provide them. To end composition you just put a single full stop (".") on a new line as you would for most CLI mail clients. You can put the message in a file and direct that into Smail: smail user@domain.com < ./messagefile. This is handy for use in scripts -- for example to notify somebody to insert backup media or that backup has finished (with success/failure reports).

Tips

Unless told to otherwise when it is called, Smail will generate the sender headers from the local user who called it. If your local machine uses a non-public FQDN this could cause an issue when routing mail to remote addresses. An increasing number of public mailservers will not route messages from addresses they cannot verify and "ryan@localhost" usually falls into that category. Some ISPs refuse to route mail (originating from within their IP range) unless the sender is on their domain. You can resolve both these issues by editing the smail config file (/etc/smail/config on Debian systems) and editing the From_field setting accordingly.

If you want messages for postmaster and root to be sent to a remote address (as in the case of my small servers), you can edit /etc/aliases after configuring Smail to set that up.

Conclusion

Smail is an excellent drop-in replacement for the popular (larger) MTAs. It is mature, stable, not resource-hungry and -- in my experience -- considerably overlooked. Its simple configuration completely negates most reasons for installing larger MTAs where they are not needed (like the ever-green "I don't want to learn a new set of config rules"). It epitomises the Unix way: it does one thing and does it well. Whilst most Desktops won't require an MTA, there are several cases where having one would be handy and installing a full-blown one would be just too much work. Enter Smail -- the lighter MTA.

Category: 

Author information

Ryan Cartwright's picture

Biography

Ryan Cartwright heads up Equitas IT Solutions who offer fair, quality and free software based solutions to the voluntary and community (non-profit) and SME sectors in the UK. He is a long-term free software user, developer and advocate. You can find him on Twitter and Identi.ca.

Most forwarded

Interview with Dave Mohyla, of DTIDATA

Dave Mohyla is the president and founder of dtidata.com, a hard drive recovery facility based in Tampa, Florida.

TM: Where are you based? What does your company do?
DTI Data recovery is based in South Pasadena, Florida which is a suburb of Tampa. We have been here for over 10 years. We operate a bio-metrically secured class 100 clean room where we perform hard drive recovery on all types of hard disks, from laptop hard drives to multi drive RAID systems.

Anybody up to writing good directory software?

Since the very beginning, directories (of any kind) have had a very central role in the internet. (I have recently grown fond of Free Web Directory. Even Slashdot can be considered a directory: a collection of great news and invaluable user-generated comments. As far as software is concerned, doing a quick search on Google about software directories will return the free (as in freedom) software directories like Savannah, SourceForge, Freshmeat and so on, followed by shareware and freeware sites such as FileBuzz, PCWin Download Center and All Freeware (great if you're looking for shareware and freeware, but definitely less comprehensive than their free-as-in-freedom counterparts).

Interview with Mark Shuttleworth

Mark Shuttleworth is the founder of Thawte, the first Certification Authority to sell public SSL certificates. After selling Thawte to Verisign, Mark moved on to training as an astronaut in Russia and visiting space. Once he got back he founded Ubuntu, the leading GNU/Linux distribution. He agreed on releasing a quick interview to Free Software Magazine.

Is better education the key to finding better software?

I read David Jonathon's article Anybody Up To Writing Good Directory Software? the other day, which got me thinking about software directories in general. As David mentioned, many of the software directories one finds when doing a quick google search are free as in beer, not as in freedom. But what interests me is the software directories that already exist, providing a combination of both free as in beer software, and open source software. Sites such as Freeware Downloads and Shareware Download don't advertise themselves as providing free as in liberty software, but each of them have a good selection of open source software available... if you know where to look.

Most emailed

Free Open Document label templates

If you’ve ever spent hours at work doing mailings, cursed your printer for printing outside the lines on your labels, or moaned “There has got to be a better way to do this,” here’s the solution you’ve been looking for. Working smarter, not harder! Worldlabel.com, a manufacture of labels offers Open Office / Libre Office labels templates for downloading in ODF format which will save you time, effort, and (if you want) make really cool-looking labels

Creating a user-centric site in Drupal

A little while ago, while talking in the #drupal mailing list, I showed my latest creation to one of the core developers there. His reaction was "Wow, I am always surprised what people use Drupal for". His surprise is somehow justified: I did create a site for a bunch of entertainers in Perth, a company set to use Drupal to take over the world with Entertainers.Biz.

Update: since writing this article, I have updated the system so that the whole booking process happens online. I will update the article accordingly!

So, why, why do people and companies develop free software?

More and more people are discovering free software. Many people only do so after weeks, or even months, of using it. I wonder, for example, how many Firefox users actually know how free Firefox really is—many of them realise that you can get it for free, but find it hard to believe that anybody can modify it and even redistribute it legally.

When the discovery is made, the first instinct is to ask: why do they do it? Programming is hard work. Even though most (if not all) programmers are driven by their higher-than-normal IQs and their amazing passion for solving problems, it’s still hard to understand why so many of them would donate so much of their time to creating something that they can’t really show off to anybody but their colleagues or geek friends.

Sure, anybody can buy laptops, and just program. No need to get a full-on lab or spend thousands of dollars in equipment. But... is that the full story?

Fun articles

Santa Claus - the most successful open source project

It dawned on me the other day, as I was shopping for the dozens of gifts it seems I have to buy every December, that Santa Claus is the most successful open source project in history. (Bridget @ Illiterarty would agree with that). Santa Claus is essentially a marketing development that is embodied by everyone who stuffs a sock, gives a gift, hosts a dinner or wishes Merry Christmas over the holiday season.

Most emailed

Editorial

When I first started thinking about Free Software Magazine, I was feeling enthusiastic about the dream. I had Dave, Gianluca, and Alan willing to help me, I had established members of the free software community willing to help me out, I had writers volunteering their time and energy for free, and I had a generous offer from OpenHosting for servers, all before I'd proved myself. There was a sense of excitement in the air, and I thought maybe, just maybe, I could make this work.

Free Software Magazine uses Apollo project management software and CRM for its everyday activities!