Set Up Internet Mail and Usenet News

Since we now have a pretty standard Unix system there are many ways to manage mail and news. What I'm going to describe is what works for me, and I make no claim that it's the best way to do things for anyone else.

Preparation

Before we actually install these packages we'll need to do some preparation. If you're the only user on your box, create another one. I always have a user called calvin, and his password is NOT hobbes. We'll use this guy to make sure that local mail stays on the box and is not sent to our smarthost.

Next, add the following to your ~/.bash_profile file:

export REPLYTO='pann@agora.rdrop.com'

substituting your own real email address, of course. We don't want anyone to try and reply to pann@ourmanpann.com because the mail would never get to us.

This next one you'll need to do as root. Add the following, on a line by itself, to your /etc/smail/config file:

queue_only

The standard debian smail setup is to have everything run automatically as if you had a full time connection to the internet. Since I don't, I modify things ever so slightly. This change is essentially in preparation for installing diald, the last step on this page. I don't want the phone dialing every time I write an outgoing email.

The next thing you need to do is create a ~/.muttrc file with the following line (using your own name and email address, of course):

my_hdr From: Pann McCuaig <pann@agora.rdrop.com>

Mutt uses the /etc/Muttrc file for system-wide configuration, and ~/.muttrc for user-level configuration. Mutt is well documented. Try

lynx /usr/doc/mutt/manual.html

Initial Mail Test

Now log in as pann (your normal login), invoke mutt, and send mail to calvin (your test user).

After you exit from mutt, execute runq. (You can do this as a normal user.) This will move the mail you just created from /var/spool/smail/input/ to /var/spool/mail/calvin.

Now log in as calvin and invoke mutt to read your mail. Take a look at the headers. Does everything look OK? If not, troubleshooting is left as an exercise for the reader.

Install and Configure fetchmail

In a nutshell, fetchmail retrieves email from your ISP and passes it off to smail.

The long story (look in /usr/doc/fetchmail/) is that it is an extremely flexible and useful program. Furthermore, the "development was also a sociological experiment," described by fetchmail author Eric S. Raymond in his now well-known paper The Cathedral and the Bazaar.

Become root and install the fetchmail package.

apt-get install fetchmail

After fetchmail is installed you must create the run control file ~/.fetchmailrc.

Here is mine:

poll agora.rdrop.com
protocol pop3
user pann
pass myveryownpassword
keep
fetchall
fetchlimit 100
postconnect /usr/bin/runq

Note that you'll need to change the argument for poll to your provider. You'll also need to fix up the user and pass lines.

The keep is only for testing. This will leave any downloaded emails on your server. We do this to make sure we don't lose any. After everything is working you'll want to delete this line.

Once you've built the ~/.fetchmailrc file, execute the following:

chmod 0600 .fetchmailrc
fetchmail --version

Fetchmail insists on the specified permissions for the run control file. Running fetchmail with the --version option will cause it to parse the run control file and print out in plain English the options selected. It will also tell you about any syntax errors in the file.

Once your run control file is error free, try it out.

pon
fetchmail
poff

If there was any mail waiting at your ISP it should now be on your machine and you should be able to read it with mutt. If there were problems, use the error messages and the man page to get things straightened out.

Generalizing Your fetchmail Setup

After having a look at the files in /usr/doc/fetchmail I decided to modify my setup for two reasons:

  1. To enable the polling of multiple hosts, possibly by multiple users;
  2. To have fetchmail run automatically every time the PPP link was up.

In /usr/doc/fetchmail are scripts named fetchmail-up and fetchmail-down. These are intended to go in the directories /etc/ppp/ip-up.d and /etc/ppp/ip-down.d, respectively.

I have found that with debian it's best to try things "out of the box" initially, and only modify them if something doesn't work. So I became root, copied the scripts where they belonged, and then did a chmod 755 on them. From examining fetchmail-up it's obvious that the ~/.fetchmailrc file needs to become /etc/fetchmailrc. So I modified the file ever so slightly, copied it to /etc/ (as root), and did a chmod 0600 to it. Then I brought up the PPP link, and sure enough, my new mail ended up in my mail spool.

Here is the modified file:

poll agora.rdrop.com with protocol pop3
user pann with password TryToGuess is pann
fetchall fetchlimit 100
postconnect /usr/bin/runq

Install and Configure slrn

The slrn package includes the programs slrn to read and post news, and slrnpull to communicate with your ISP's news server.

Install slrn by becoming root and executing

apt-get install slrn

During installation you will be asked several questions. The questions, along with my answers to them, are duplicated here. You will, of course, want to modify my answers to suit your installation.

Slrn Configuration
------------------
What news server (NNTP server) should I use for reading and posting news?
Enter its full name:

hermes.rdrop.com

Do you want a cron job to be set up to automatically refresh the newsgroup descriptions for you? [y/n]

no

Do you want /etc/ppp/ip-up.d/slrn to refresh the newsgroup descriptions? [y/n]

no

Do you plan to use slrnpull to download a small local news spool for offline news reading? [y/n]

yes

Do you want a cron job to be set up to automatically run slrnpull? [y/n]

no

Do you want /etc/ppp/ip-up.d/slrn to run slrnpull? [y/n]

yes

Current configuration:
Refresh newsgroup descriptions by hand.
Use slrnpull to generate a local news spool.
Run slrnpull via /etc/ppp/ip-up.d/slrn.

Are you happy with this configuration? [Y/n]

yes

Are you online now? If so, I'd like to refresh the newsgroup descriptions. May I? [y/N]

no

These files have been created by the installation and configuration:

/etc/slrnget.conf
/etc/ppp/ip-up.d/slrn
/var/spool/slrnpull/slrnpull.conf

The last file must be modified to pull down the articles you want. Here is the relevant information from my slrnpull.conf:

default 300 7

agora.general
pdx.forsale
or.forsale
linux.jobs

After you've fixed up slrnpull.conf you need to run

slrnpull --new-groups

(as root). The last thing you'll need to do as root is

chmod 777 /var/spool/slrnpull/out.going

if you want users to be able to post articles. Read /usr/doc/slrn/README.Debian to see why this is necessary and a possible alternative.

The rest of the configuration is user-specific.

You need a ~/.slrnrc file set up for slrnpull. You'll only need to modify the last two lines.

% This is a minimal .slrnrc file for use with slrn when it is used to
% read from an slrnpull spool directory. Here I assume that the
% SLRNPULL_ROOT directory is /var/spool/slrnpull.
% Note that PULL_SUPPORT must be enabled in slrnfeat.h.

set spool_inn_root "/var/spool/slrnpull"
set spool_root "/var/spool/slrnpull/news"
set spool_nov_root "/var/spool/slrnpull/news"
set read_active 1
set use_slrnpull 1

% Don't forget to set these up properly.

hostname "agora.rdrop.com"
set username "pann"

You'll need to run the following command after you create the .slrnrc file.

slrn --spool -f /home/pann/.jnewsrc -create

You'll find yourself in slrn with all the groups you've specified listed, with no articles. You'll want to use the s key to subscribe to all of them.

Normally when you want to read news, you'll use the command

slrn --spool

Articles will not be expired automatically unless you set up a cron job to do it. If you want to do it manually, you need to periodically execute

slrnpull --expire

as root.

There are many configuration options not described here, but well described in the documentation accompanying the slrn package. I've tried to give you enough to get slrn up and running, set up so it will get news every time the PPP link comes up. Further customization is up to you. Enjoy.

Install and Configure diald

Now that mail and news is coming in every time you bring up the PPP link, you might want to think about installing a slick little daemon called diald that will bring up the PPP link automatically any time a packet needs to find its way to a machine not on your local network. Here's how.

apt-get install diald

After installation of diald and during configuration, you'll be informed that diald won't run without an /etc/diald/diald.options file. So you'll have to create one.

The top part of my diald.options file came from the example in /usr/doc/diald/examples/diald.options.gz

# /etc/diald/diald.options
#

# diald log file: do not change.
accounting-log /var/log/diald.log

# diald monitoring pipe: do not change.
fifo /var/run/diald.fifo

# This turns on full debugging.
#debug 31

The bottom part of my diald.options file came from the example in

man diald-examples

A Leaf Node with Dynamic Local Address using PPP

mode ppp
connect /etc/diald/connect
device /dev/ttyS1
speed 115200
modem
lock
crtscts
local 192.168.0.1
remote 192.168.0.2
dynamic
defaultroute
include /etc/diald/standard.filter

I modified two lines of the bottom part to match my setup:

connect "/usr/sbin/chat -f /etc/chatscripts/provider"
device /dev/ttyS0

And finally I inserted a line so that pppd would run properly using the ready-made provider chatscript:

pppd-options noproxyarp noauth user pann

So here's what the whole file looks like:

# /etc/diald/diald.options
#

# diald log file: do not change.
accounting-log /var/log/diald.log

# diald monitoring pipe: do not change.
fifo /var/run/diald.fifo

# This turns on full debugging.
#debug 31

pppd-options noproxyarp noauth user pann

mode ppp
connect "/usr/sbin/chat -f /etc/chatscripts/provider"
device /dev/ttyS0
speed 115200
modem
lock
crtscts
local 192.168.0.1
remote 192.168.0.2
dynamic
defaultroute
include /etc/diald/standard.filter

Once you've got /etc/diald/diald.options in place, with permissions 0644, execute (as root)

/etc/init.d/diald start

and diald should start up. Once it's running, test it (as a normal user) with

ping -c1 www.debian.org

The phone should dial and the PPP link should come up, and you should see the results of the ping command.

You only needed to start diald by hand because you were missing the diald.options file. It will be started automatically after this anytime you reboot your machine.


Learn how to install pine from source.

Return to Our Man Pann's Linux Page.

Pacifier Online is my Internet Service Provider.

Hurricane Electric provides me with Web/Domain Hosting Services.

Last modified: 29-Apr-99 by Pann McCuaig.

Copyright 1999 by Pann McCuaig. All rights reserved.