Archive for the 'Email' CategoryPage 2 of 2

An Anti-Spam gateway #3: Postfix

(NOTE: this is part of the “An Anti-Spam gateway” series)

So, at last, we’re getting our hands dirty. It’s time to separate the boys from the men, or something. :)

Now, as I was writing this, I had a decision to make. Should this part, called “Postfix”, include all the Postfix-related instructions, which will produce a non-working, non-testable mail server until the rest of the stuff is installed? Or should this part have enough to create a standard gateway, not depending (yet) on SpamAssassin, ClamAV and the rest - and, only in THOSE parts, will the instructions for configuring Postfix to use them appear?

I’ve decided to do it the latter way. It’s important to be able to test each part of the gateway as you install it, instead of doing everything and only “turning it on” at the end, with a myriad possible points of failure.

So, to install Postfix: go to http://www.postfix.org/download.html, choose the closest mirror, and download the most recent stable version of Postfix (at this time, it’s 2.2 patchlevel 5, or 2.2.5). Uncompress it, enter its directory, and then…

AUXLIBS='-ldb' CCARGS='-DHAS_DB' OPT='-O2' DEBUG='' make
AUXLIBS='-ldb' CCARGS='-DHAS_DB' OPT='-O2' DEBUG='' make install

There, an installed Postfix. (accept the defaults at the end.) The configuration files are at /etc/postfix, so let’s go there and make a few changes to main.cf… in the next part, since this one is becoming too long.

An Anti-Spam gateway #2: A note about compiling on Linux

(NOTE: this is part of the “An Anti-Spam gateway” series)

These days, most Linux distributions, especially the RPM-based ones like Fedora, Red Hat or SUSE, increasingly assume that “nobody compiles stuff anymore”. Due to that, they don’t install, by default, the development parts of most libraries and applications.

An example: by default, a distro will install OpenSSL, with the openssl package. But that’s the library files only. It “gives” OpenSSL to other RPMs that need it, but, when you try to compile any program to use OpenSSL, it will fail (or, possibly worse - it will compile, but without OpenSSL support, and you may fail to notice it), because you are missing the header files.

They’re in the openssl-devel package.

So, from now on, through the rest of this series, pay attention when compiling (mostly in the ./configure part). If it fails, or if it passes but says that you are missing an important library, the thing to do is probably to look for the missing *-devel package, and install it.

Incidentally, this is not a problem in the BSDs.

An Anti-Spam gateway #1: Initial stuff

(NOTE: this is part of the “An Anti-Spam gateway” series)

Before we begin to actually get our hands dirty :), here are a few things to note:

  • As I said in the introduction, this is a recipe, not a reference manual. There are certainly many other ways to do something like this, but I won’t be exploring them.
  • I’m not explaining basic stuff like “to uncompress a .tar.gz file, type tar xzf filename. If you don’t know things like that, this series really isn’t for you. Sorry about that.
  • The required hardware depends on the company / organization size, and on how much mail you receive. A Pentium III with 128 MB of RAM is more than enough for a company with 1000 employees. No, that’s not a typo - if you’re not using Windows or Oracle (yuck), you don’t need 64-CPU supercomputers with terabytes of RAM. :)
  • The operating system should be a Unix-like system with a C compiler such as gcc. Most Linux distributions include everything you need, although you may have to manually select the “Development” packages during installation, or add them later. Other alternatives include OpenBSD (my personal favorite, and the server this blog runs on), FreeBSD, NetBSD, Solaris, etc.. Anything but Windows or SCO. :)
  • I will be compiling most of the software manually. Using packages (such as RPMs, or BSD ports) is possible, but they may not activate some needed option by default. It’s up to you.
  • This machine will be a gateway — that is, it won’t have mailboxes, it will just receive mail from the Internet, refuse messages from known open relays, tag spam messages by prepending “*** SPAM ***” to the message subjects, and stop emails with viruses, warning the recipient that someone tried to send them a virus. Then, if the mail wasn’t stopped, it delivers it (or the virus warning message) to the “real” email server, which has the actual mailboxes.
  • For simplification, I’m assuming that the machine has only one network card, and has the IP adress 10.0.0.1 (supposedly, some firewall is redirecting port 25 from the outside to this address). The “real” mail server has the address 10.0.0.2. More complex configurations are possible, but, again, I’m not exploring them here.
  • I’m also assuming that the gateway has unrestricted outbound Internet access. (it only needs inbound access to port 25). After it’s working, you may possibly want to restrict it somewhat (though I think it it’s a bit useless), but it’ll always need to do DNS queries, access some spam databases like Razor, and update ClamAV.

So, before you go to part 2, you should have a box with one network card configured as 10.0.0.1, running an Unix-like OS with a C compiler.

An Anti-Spam gateway #0: Introduction

(NOTE: this is part of the “An Anti-Spam gateway” series)

“An Anti-Spam gateway” is the Tlog’s third series.

In it, I will write about how to use a Unix-like free operating system such as Linux or OpenBSD, using Postfix, amavisd-new, SpamAssassin with MySQL, and ClamAV to create a free, open source, efficient mail gateway, for tagging spam (I don’t believe in deleting it automatically, that should be up to the users themselves) and stopping email viruses.

While I plan to make this not too advanced, I won’t deal with the basics here, like the installation of the OS, or uncompressing files, and so on.

Also, I won’t explore all the alternatives. This is a HOWTO, not a reference manual. Think of it as a recipe: while a cook is free to change some of the ingredients or procedures, the recipe doesn’t usually say “if you do this instead, that will be the result”. For instance, you may not require an anti-virus, or may want to use a different one, or may want to delete spam messages above a certain score, or may not use MySQL for the Bayes database… all of those possibilities are perfectly fine. I just won’t explore them here.

I hope this series is useful. Few companies, except perhaps multinationals, have gateways as good as this one will be. Trust me. ;) I may be missing out the money I could make by selling “consulting” to companies to do this, instead of just posting the information on the net; however, I don’t want to make a living of installing and configuring email gateways :), and, also, if the majority of companies (and possibly even ISPs) adopt something like this, then there may be, in the future, less spam out there. Making the world a better place, and all that stuff. A guy can dream.

Thunderbird 1.5b2

Mozilla Thunderbird 1.5b2 is out (saw it on Ricardo Saramago’s blog).

Note: the “what’s new” list in the 1.5b2 page lists what’s new since 1.0.x, not since 1.5b1, contrarily to what it looks like.

As I don’t use an email client at home anymore, I’ll only test this version when I get back from holidays…

Yahoo! Mail beta

Does GMail have competition?

From what I can see, it looks like a “normal” email program… but in the browser. And they say it’s responsive like an email program.

I have 2 Yahoo! Mail accounts, though I don’t use them these days - I use fetchyahoo to redirect them to my GMail account. But if I get into the beta… I may say something more here. :)

Thunderbird 1.5b1

Shortly after Firefox 1.5b1, the new beta of Mozilla Thunderbird is also out.

I don’t use an email client at home (I use GMail), but I’ve just updated Thunderbird from 1.0.6 to 1.5b1 at work (Linux). So far, so good. No crashes (these betas have been at least as stable as the latest stable versions, which is impressive). New preferences look, just like Firefox. Spell checking as you type (may be of interest to many people, but I turned it off in less than a minute :)).

Not a lot of “wow” stuff here, but then again, it’s a mail client. :)

How to use anti-spam filters

Many people these days use, either individually (using Mozilla Thunderbird, for instance), company-wide, or in their email service (such as GMail, Hotmail, Yahoo! Mail, etc.) “learning” anti-spam filters (also called “bayesian filters”). But how many people use them correctly?

You see, the thing about those filters is that they have to be taught. And many people simply ignore (or are unaware of) that part, and the filters remain inefficient and untrustable for them. Some spam keeps arriving in their inbox, and they have to continuously check the “Spam” folder for false positives (legitimate mails wrongly tagged as spam).

Which is sad, because that’s an easily fixable situation.

To put it simply: you should ensure that every mail, when deleted, was previously correctly tagged, either as spam or as non-spam. That’s how the filters learn and improve.

For instance, let’s say that a spam mail slips through the filter and arrives in your inbox. What should you do? Many people simple delete it - thus giving the filter the message: “this was not spam, I’ve simply deleted a normal message.” In other words, the filter has just learned the wrong thing. What you should have done was to tag it as spam first (in GMail, for instance, the button is labeled “Report Spam”), and then go to the Spam folder, and then delete it there. By doing this, the filter learned what you wanted it to learn - that that mail is spam (and so are mails like it).

Another possibility is a false positive. A legitimate mail goes (wrongly) to your Spam folder. Should you read it and delete it? No! By doing that, you’re reinforcing the error, you’re telling the filter that that mail was, indeed, spam. You should remove the “Spam” tag from that mail before you delete it (for instance, in GMail, the button is called “Not Spam”).

Another common error: you subscribe to some site’s mailing list, and you find out that more than half of the mails you receive from there simply don’t interest you. It may be tempting to simply tag those as spam, and get rid of them forever that way. But that’s the wrong thing to do - they’re not really spam, since you subscribed to that list; they’re just not interesting to you. What you should do is simply unsubscribe to the list - or, if a part of those mails actually interest you, you merely delete those that don’t. By reporting them as spam, you’ll keep receiving them - they’ll just go to the Spam folder. All of them, even those that might interest you. You’ll also be “confusing” the filter; those mails are legitimate. It’s like punishing a dog for obeying you - you’ll only be sending mixed messages, and confusing the hell out of the poor thing.

If, instead, you do all of this correctly, then after a couple of months your filters will actually become trustworthy - you’ll almost never see any spam mail in your inbox, and you can be virtually sure that what is in your Spam folder is spam.




Creative Commons Attribution-NonCommercial-NoDerivs 2.5 Portugal
Creative Commons Attribution-NonCommercial-NoDerivs 2.5 Portugal