FreeBSD  Release  11.0  Install  Guide

Home______________________________________________________________________

 

Fetchmail Port / Getting Your ISP Email To FBSD

To get email that is stored in your ISP mailbox waiting to be picked up and delivered to your user on your local FBSD box, you have to install another FBSD application. Fetchmail is a full-featured, robust, remote-mail retrieval and forwarding utility intended to be used over on-demand TCP/IP PPP connections. It supports every remote-mail protocol now in use on the Internet: POP2, POP3, RPOP, APOP, KPOP, all flavors of IMAP, ETRN, and ODMR. It can even support IPv6 and IPSEC. It may also be useful as a message transfer agent for ISP sites which refuse for security reasons to permit (sender-initiated) SMTP transactions for collecting email.

For the Fetchmail Reference Manual see

http://www.fetchmail.info//fetchmail-man.html

The home page is at http://www.fetchmail.info

Fetchmail is commonly used to access your ISP email account using the pop3 protocol by logging into your ISP email server as you, retrieving the email, and delivering it to SMTP port 25 where the FBSD sendmail server is listening. Sendmail does not know the difference between this method or receiving public inbound email directed by a domain name, because in both cases email just shows up at its front door.

The fetchmail program is installed as a single system-wide fetchmail daemon. It starts as a daemon at boot time and keeps running to check a single or multiple ISP email accounts on a timed cycle. The contents from ISP email accounts can be targeted to individual user email accounts on the FBSD system or combined into a single FBSD user email account by control statements in it's control file. 

 

Fetchmail Installation Instructions

pkg_add Ėrv fetchmail

rehash

After the package is installed, you are ready to manually create fetchmail's run time control options file. You're going to do this as root so you can test the control options file before enabling it as a boot time task.

cd /root/

ee .fetchmailrc

set postmaster root
set no bouncemail
set no spambounce
 
# Example of fetching email from individual ISP email accounts and
# populating their sendmail server mailboxes.
# User statements show use of added readability words.
# Of course each ISP account has its own password.
poll mail.manbay.net, protocol pop3, no dns
user dadisp there with password xxxxxx is dadfbsd here
user momisp there with password xxxxxx is momfbsd here
user tomisp there with password xxxxxx is tomfbsd here
user bobisp there with password xxxxxx is bobfbsd here
#
###################### End of File #####################################

postmaster is the account name of the FBSD user who will be the last-resort email recipient. root is a valid entry; It can be any FBSD user you want.

bouncemail & spambounce logical happened at the ISP so anything that fetchmail/sendmail thinks is wrong is really wrong, so 'no' means direct error email to postmaster.

The poll statement is the main control statement for specifying your target ISP and providing the account information to login and how your email is to be handled by fetchmail as it hands it off to sendmail.

Replace mail.manbay.com with the name of your ISP pop3 email server.

Replace tomisp with the account name of your ISP email account that you want to retrieve the email from.

Replace xxxxxx with the password of the ISP tomisp account.

Replace tomfbsd with the account name on FBSD you want the retrieved email put into. This is the account on the FBSD box where fetchmail will deposit the email it gets from your ISP.

For each ISP account that you want to retrieve email for and populate the userís sendmail mailbox, just add another user statement following the same syntax.

Installer Note: The FBSD account names you substituted for "tomfbsd" have to be created by adduser or pw before you use fetchmail.

For security concerns you have to change the /root/.fetchmailrc file permissions to 700 (u=rwx,g=,o=), on the command line enter:

chmod 700 /root/.fetchmailrc

In daemon mode there are no error messages coming out on the screen. They are going to the syslog facility named mail. The mail facility is also used by sendmail. The message level of mail.info posts an entry in the log for every time fetchmail is executed, which is every 5 minuets in daemon mode. This just fills up the log file with useless information. To correct this problem syslog.conf has to be updated. Change the mail.info statement so it look like this.

ee /etc/syslog.conf

mail.notice     /var/log/maillog

To activate the changes to /etc/syslog.conf you can reboot or force the syslogd task into re-reading /etc/syslog.conf by issuing this console command
/etc/rc.d/syslogd reload

 

Testing Fetchmail

You are now ready to perform your first test of fetchmail. On the command line enter:

fetchmail -v -c

The -v option creates verbose messages.

The -c option means just check my ISP email account and tell me how many emails are there. At this point you just want to see if you can log in to your ISP account.

Here is what the results should look like

fetchmail: 6.3.8 querying mail.manbay.com (protocol POP3) at Fri Mar 9
00:18:12 2007: poll started
fetchmail: POP3< +OK mail.manbay.com POP3 server (Post.Office v3.5.3 release
223 with ZPOP version 1.0 ID# 0-52377U2500L250S0V35) ready Fri, 9 Mar 2007
00:22:35 -0500
fetchmail: POP3> USER tomisp
fetchmail: POP3< +OK Password required for tomisp
fetchmail: POP3> PASS *
fetchmail: POP3< +OK Maildrop has 1 messages (6287 octets)
fetchmail: POP3> STAT
fetchmail: POP3< +OK 1 6287
fetchmail: POP3> LAST
fetchmail: POP3< +OK 0
1 message for tomisp at mail.manbay.com (6287 octets).
fetchmail: POP3> QUIT
fetchmail: POP3< +OK mail.manbay.com POP3 server closing connection
fetchmail: 6.3.8 querying mail.manbay.com (protocol POP3) at Fri Mar 9
00:18:16 2007: poll completed
fetchmail: normal termination, status 0

The above results will vary depending on what pop3 server software your ISP is using. If you did not receive something close to this you have problems. The last line status 0 is a return code. Status 1 means no mail to retrieve. See the fetchmail manual for the meanings of each status return code. The most common error here is you have an incorrect name for your ISP pop3 email server. If you are having problems logging in, call your ISP to verify your email account name and password and the email server name.

After testing the control options result in good login to your ISP email account next step is to test downloading ISP email to your FBSD system.

Issue this command to fetch ISP email and put it into your FBSD user email

fetchmail -d 300 -f /root/.fetchmailrc --syslog

The -d 300 option says run fetchmail in daemon mode checking email every 5 minutes. The 300 value is 5 minutes in seconds. You can change the interval to what ever you want, just as long you specify it in seconds.

The --syslog tells fetchmail to use the syslog facility.

Issue this command to stop fetchmail daemon

fetchmail -q

Hit ALT + F2 at same time to open another session window. Login to the target FBSD email account you had Fetchmail deliver the ISP email to. Use Mail command to verify email was delivered.

 

Boot time enable

To set up fetchmail to automatically start up in daemon mode at boot time.

Add to /etc/rc.conf:

ee /etc/rc.conf

fetchmail_enable="YES"

Copy fetchmail's run time control options file to boot time location;

cp /root/.fetchmailrc /usr/local/etc/fetchmailrc

Give it correct ownership

chown fetchmail /usr/local/etc/fetchmailrc

 

If you want to change the default ISP email server polling interval time from 900 seconds (ie 15 minutes)to say 300 seconds (5 minutes)

ee /usr/local/etc/rc.d/fetchmail

Look for line 80 ${fetchmail_polling_interval="900"} and change the 900 to 300

 

To control the fetchmail daemon use these commands from the command line

usr/local/etc/rc.d/fetchmail start

usr/local/etc/rc.d/fetchmail restart

usr/local/etc/rc.d/fetchmail stop

 

Previous Page                                        Next Page         

This FreeBSD Install Guide is an public domain HOW-TO. This content may be reproduced, in any form or by any means, and used by all without permission in writing from the author.