It is a known fact that gmail’s spam filters get the job done.
I am working with spamassassin on local mail setups and i want spamassasin to learn automatically from my gmail Spam folder.
So is it possible?
Of course it is possible.
First we have to get all the mails from our gmail account into a local dummy mail account (easy we’ll use getmail) and then we have to educate spamassasin from our local dummy mail account (sa-learn).
one config file and two commands via cron will do the work.
First the getmailrc (i shall not bother with the getmail & spamassassin installation or setup).
/root/.getmail/getmailrc
[options]
delete = false
message_log = /var/log/getmail.log
verbose = 0
read_all = false
[retriever]
type = SimpleIMAPSSLRetriever
server = imap.gmail.com
mailboxes = ("[Gmail]/Spam",)
username = username@example.com
password = XXXXXXXXXXXXXXX
[destination]
type = Mboxrd
path = /var/spool/mail/gmail_spam
user = nobody
So now when we execute: getmail
every new mail is gmail spam folder will be downloaded into /var/spool/mail/gmail_spam
Next we need to execute sa-learn
sa-learn --spam --mbox /var/spool/mail/gmail_spam
Thats it!
Simple as that!
Dont forget to add the below cron entries:
@daily getmail &> /dev/null
@daily sa-learn --spam --mbox /var/spool/mail/gmail_spam &> /dev/null