# How to detect spam on a mailserver before downloading it?



## neilms (Oct 4, 2013)

I was wondering if it is possible to set up a system so that email is checked and filtered for spam while it is on the ISP's delivery server. For example, suppose my ISP uses a IMAP server for email. 

The problem is that using traditional email software like Outlook Express, Icedove, Evolution etc, spam gets downloaded and it is necessary to use filters in the program to eliminate the spam.

In FreeBSD is it possible to use some software that interrogates the mail server and then does all filtering remotely before delivering the sanitised mail to my computer? If so, how difficult is it to set a system like that up?


----------



## wblock@ (Oct 4, 2013)

It depends on the ISP and what access the user has to an account on the mailserver.  With a login account, you can use mail/procmail, mail/maildrop, or maybe heavier filtering options.


----------



## neilms (Oct 5, 2013)

wblock@ said:
			
		

> It depends on the ISP and what access the user has to an account on the mailserver.  With a login account, you can use mail/procmail, mail/maildrop, or maybe heavier filtering options.



I just have a regular ISP. Have you set up either of these programs before? I am trying to avoid anything that is too complicated at the moment.


----------



## kpa (Oct 5, 2013)

You don't do any "remote filtering" with POP3 or IMAP protocols, all processing has to happen locally on messages that you have fetched from your mail account. And no, the standard SMTP protocol is not available in your case because the mail has already been delivered to you mail account at your ISP. I would just fetch everything and feed the message to a spam filter locally marking recognized spam as such.


----------



## wblock@ (Oct 5, 2013)

neilms said:
			
		

> I just have a regular ISP. Have you set up either of these programs before? I am trying to avoid anything that is too complicated at the moment.



I've used both.  Here is an article on setting up mail/maildrop: Switching From procmail To maildrop.  This would filter locally (on the ISP's machine).  The remaining mail could be accessed with IMAP (I think, untested).

Most ISPs do not provide shell accounts any more.  Or IMAP, for that matter.  But a lot have webmail with programmable filters.


----------



## SirDice (Oct 7, 2013)

Unfortunately spammers don't use RFC-3514. The only way to find out if it's spam or not is by looking at the message as a whole. You need to read the headers and the body to figure out if it's spam or not. That means you'll have to download the message, even if you're using IMAP. Even a receiving SMTP server needs to read the whole message.


----------

