Blue Flower

Getting fetchmail to work with qmail-scanner

In order to get fetchmail to work with qmail-scanner, there are a few things we need to do. The first thing we need to do is to setup fetchmail so it delivers correctly. To do this, what we need is login as root and then create a .fetchmailrc file with the delivery information in it. Start by doing the following:

# cd ~root

# vi .fetchmailrc

You will want to put the following information in the .fetchmailrc file:

poll mail.server.name
with protocol pop3
username user password mypass is This email address is being protected from spambots. You need JavaScript enabled to view it. here

The mail.server.name is the complete pop3 server you want to pull your messages from. The protocol can vary but is most often pop3. The next line gets a little more interesting. We are going to pull the mail for user using password of mypass and then deliver it to This email address is being protected from spambots. You need JavaScript enabled to view it. . The here tells the fetchmail program to deliver the message locally.

Please note that if you want to test this first just to make sure things are working okay, put the word keep at the end of the username section like so:

username user password mypass is This email address is being protected from spambots. You need JavaScript enabled to view it. here keep

This will keep the messages on the server so that way you can check to make sure this works okay before you start ripping messages off you boxes :-)

You can have multiple lines with the username in it like so:

poll mail.server.name
with protocol pop3
username user password mypass is This email address is being protected from spambots. You need JavaScript enabled to view it. here

username user1 password mypass is This email address is being protected from spambots. You need JavaScript enabled to view it. here

username user2 password mypass is This email address is being protected from spambots. You need JavaScript enabled to view it. here

You can also poll multiple pop3/imap servers

poll mail.server.name
with protocol pop3
username user password mypass is This email address is being protected from spambots. You need JavaScript enabled to view it. here

poll mail.server3.name
with protocol IMAP
username user4 password mypass is This email address is being protected from spambots. You need JavaScript enabled to view it. here

poll mail.server4.name
with protocol pop3
username user5 password mypass is This email address is being protected from spambots. You need JavaScript enabled to view it. here

So the .fetchmailrc file can have many different ways to pull messages from different types of mail servers.

If you are using John Simpsons qmail-smtpd/run script, please add the following 2 lines to your .fetchmailrc file. You will want to add this to the section under the protocol section but before the username section. Please replace x.x.x.x with the the IP Address of your qmail server and the cert path if applicable. This is what a typical entry would look like:

poll mail.server.name
with protocol pop3
sslcertck sslcertpath '/var/qmail/control'
smtphost x.x.x.x

username user password mypass is This email address is being protected from spambots. You need JavaScript enabled to view it. here

The hard part is pretty much over. Now what we need to do is add the qmail-filtering mechanisim to /etc/smtp or if you’re using John Simpsons qmail-smtpd/run file. It would be /etc/tcp/smtp so we’ll want to modify the following entry in it:

127.:allow,RELAY="",QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl",QS_SPAMASSASSIN="on"

If you’re using the qmailrocks standard qmail-smtpd/run file, just type in qmailctl cdb.

If you’re using the John Simpson qmail-smtpd/run file, type in the following:

# cd /etc/tcp

# gmake

Start fetchmail by typing:

# fetchmail -d 300 -L /var/log/fetch

the -d switch tells fetchmail to check the mail every 300 seconds (Every 5 mins) and the -L tells the log file path. The log file is optional. If you check the log file, it should start pulling messages.

You should be off and running!