chrislale@users.sourceforge.net
Revision History | ||
---|---|---|
Revision 0.1 | 23 January 2004 | Revised by: cl |
Initial release |
To spam is to mass-mail unrequested identical or nearly-identical email messages, particularly those containing advertising. Especially used when the mail addresses have been culled from network traffic or databases without the consent of the recipients (see the Linux Dictionary).
Firewalls do not protect you against spam, but you can use other software to identify and filter out junk email.
The type of software that manages email on your computer falls into three loosely defined catagories: Mail Transport Agent, Mail Delivery Agent and Mail User Agent. There is an article describing generic mail flow. These mail agents are often incorporated into a single software application (eg evolution, mozilla mail, etc). Figure 1 shows a typical system for receiving email.
Figure 1: the major components of a mail system dealing with incoming mail.
Mail Transport Agent (MTA), sometimes referred to as a Mail Transfer Agent. A mail transport agent is software that enables mail to travel from one mail system to another. Your provider's server uses an MTA to send you your mail. You must have an MTA at your end of the connection. A standard Debian installation uses exim, but you may come across others eg sendmail, smail, qmail, etc. Typically, the MTA passes the mail onto an MDA.
Mail Delivery Agent (MDA), sometimes referred to as a Local Delivery Agent (LDA). A mail delivery agent is software that takes mail from an MTA and passes it on to a mailbox or another MTA. A standard Debian installation uses procmail, although there are others eg deliver.
Mail User Agent (MUA). A mail user agent is the software that enables a user to write, send, receive and read email. A standard Debian installation uses mail for local mail. Other mail user agents include elm, pine, eudora, pegasus, etc.
Mail from your provider normally reaches you using the POP3 protocol. A protocol is a set of rules that govern how things communicate over the network (see theLinux dictionary).
A user can read the mail using mail as the MUA. The command is:
mail local-user-2 |
X-Spam-Status: Yes, hits=5.7 required=5.0 tests=VIAGRA,BASE64_ENC_TEXT,SUBJ_ALL_CAPS version=2.20 X-Spam-Flag: YES X-Spam-Level: ***** X-Spam-Checker-Version: SpamAssassin 2.20 (devel $Id: spam.html.en,v 1.1 2004/04/30 21:50:38 chrislale Exp $) X-Spam-Prev-Content-Type: text/plain X-Spam-Prev-Content-Transfer-Encoding: base64 X-Evolution-Source: mbox:/var/mail/local-user |
spamassassin also modifies the subject line of suspected spam.
Subject: *****SPAM***** WEEKEND VIAGRA |
SPAM: -------------------- Start SpamAssassin results ---------------------- SPAM: This mail is probably spam. The original message has been altered SPAM: so you can recognise or block similar unwanted mail in future. SPAM: See http://spamassassin.org/tag/ for more details. SPAM: SPAM: Content analysis details: (5.7 hits, 5 required) SPAM: Hit! (2.4 points) BODY: Plugs Viagra SPAM: Hit! (1.4 points) Message text disguised using base-64 encoding SPAM: Hit! (1.9 points) Subject is all capitals SPAM: SPAM: -------------------- End of SpamAssassin results --------------------- |
Information you need | Details of the account with your provider |
your provider's telephone number |
|
the address of your provider's POP3 server (for your incoming mail) |
|
your username for logging in to the POP3 server |
|
your password for logging in to the POP3 server |
|
the address of your provider's SMTP server (for your outgoing mail) |
|
Pseudonym | Description | Real name on your system |
firstname surname | your full name |
|
local-host | the name of your (local) computer. (You can find out by entering hostname at the command prompt |
|
local-user or local-user@local-host | your username on the local computer |
|
Example | the account name used evolution to identify your provider (eg the provider's name) |
|
Pseudonym | Description | Real name on your system |
remote-user-name | your username on the remote server (isp or hosted server) |
|
remote-user-name@example.net | the name of your account on the remote server |
|
mail.example.net | the name of the remote POP3 mail server (that your incoming mail comes from) |
|
smtp.example.net | the name of the remote SMTP mail server (that your outgoing mail goes to) |
|
The first step is to configure and test evolution so that it sends mail directly to your provider's server, and receives mail directly from it.
Later, you must change evolution's configuration for incoming mail. This is to allow other software applications to take over some of the processing of mail before it reaches evolution.
$ su Password: ******* # apt-get install evolution |
Exit from root when the installation is complete.
# exit $ |
Run evolution as a normal user.
$ apt-get install evolution |
Menu bar File Go to Folder ... Go to folder ... dialogue Go to folder ... dialogue Inbox OK |
Menu bar Tools Mail Settings ... Add Mail settings dialogue Accounts tab Add |
This brings up the evolution Account Assistant's Mail Configuration dialogue .
Mail Configuration dialogue
Click "Next" to begin
Next
|
Identity dialogue
Required information
Full name: firstname surname
Email address: remote-user-name@example.net
Next
|
Receiving Email dialogue Server Type: POP Configuration Host: mail.example.net Username: remote-user-name Authentication Authentication Type: Password Remember this password Next Checking for New Mail Automatically check for new mail every 10 minute(s) Receiving Email dialogue Next |
Enter details of the email server that you send emails to. (This is usually an SMTP server.)
Sending Email dialogue Server Type: SMTP Server Configuration Host: smtp.example.net Next |
Account Management dialogue Account Information Name: Example Next Done Finish |
Use either the File menu or New Message button to open the Compose a 'message' dialogue.
Menu bar
File
New
Mail Message
|
Button bar
New Message
|
Compose a message dialogue
To: remote-user-name@example.net
Subject: Evolution test 1
Send
|
Button bar
Send / Receive
|
Move on to the next section when you are sure that the system is working correctly.
eximis a mail transfer agent (MTA).
The Exim manual describes exim like this. exim “contains facilities for verifying incoming sender and recipient addresses, for refusing mail from specified hosts, networks, or senders, and for controlling mail relaying”. and the Debian Reference. It sounds complicated! This is where Debian comes to the rescue. You install exim from a Debian package (.deb file). exim is probably already configured and working.
The inetd.conf file starts exim running every time you boot your computer (see Exim's README.Debian file).
You may find the newbieDoc article “A simple configuration of Exim” useful.
$ mail local-user Subject: local message hello ctrl-D Cc: ctrl-D $ |
$ cat /var/mail/local-user From local-user@local-host Wed Feb 04 12:11:46 2004 Return-path: <local-user@local-host> Envelope-to: local-user@local-host Received: from local-user by local-host with local (Exim 3.35 #1 (Debian)) id 1AoLsg-0000in-00 for <local-user@local-host>; Wed, 04 Feb 2004 12:11:46 +0000 To: <local-user@local-host> Subject: local message Message-Id: <E1AoLsg-0000in-00@local-host> From: local-user <local-user@local-host> Date: Wed, 04 Feb 2004 12:11:46 +0000 Status: O hello $ |
Read the message using mail. Use the 'enter' key to open the message and enter 'q' to quit.
$ mail Mail version 8.1.2 01/15/2001. Type ? for help. "/var/mail/local-user": 1 message 1 new >N 1 local-user@local-host Wed Feb 04 12:11 14/394 local message hello & q Saved 1 message in /home/local-user/mbox $ |
Mail stores messages in the /home/local-user/mbox file. You can check this too.
$ cat /home/local-user/mbox |
|/usr/bin/procmail |
$ chmod -v 0644 /home/local-user/.forward mode of `/home/local-user/.forward' changed to 0644 (rw-r--r--) |
In a previous section on configuring Evolution to send and retrieve mail, you configured evolution to receive mail from directly from your provider's server. The next step is to get a different application (fetchmail) to do the job instead! There is a good reason for this. You must examine each message for spam before it reaches evolution. fetchmail will collect the mail and forward it to the local mailbox (/var/mail/local-user). exim, procmail and spamassassin will deal with spam on the way to the mail box (see figure 5). You may find the newbieDoc article “Fetchmail configuration” useful.
Don't worry about spamassassin yet - get fetchmail working first.
Figure 5: Fetchmail delivers incoming remote mail into the local mail system.
fetchmailretrieves the mail from your provider's server and forwards it to your local email folder (see figure 5). If you logged into your computer as local-user, fetchmail will place it in /var/mail/local-user. This means that you must reconfigure evolution to retrieve the mail from /var/mail/local-user instead of directly from the remote POP3 account. This is so that the mail can be processed before evolution receives it.
$ su Password: ******* # synaptic or # aptitude or # apt-get install fetchmail fetchmail-common fetchmailconf |
# exit $ |
You must make the following configuration choices during installation:
Read the warnings and locations of related documentation
OK |
Read the information related to the installation of a system-wide fetchmail daemon
Install a system-wide fetchmail service? Yes |
Run system-wide fetchmail as root? No |
OK |
Invoke fetchmailconf from the command line as a normal user. It runs as an X11 application.
$ fetchmailconf |
fetchmail launcher dialogue
Configure fetchmail
|
Choose the 'Novice Configuration'.
fetchmail configurator dialogue
Novice Configuration
|
fetchmail novice configurator dialogue Fetchmail Run Controls Poll interval: 30 (seconds) Remote Mail Server Configurations New Server: mail.example.net |
Either double-click or press the <Enter > key.
Enter the protocol of the remote mail server and the user name you use to log into it.
Fetchmail host mail.example.net dialogue
Protocol
POP3
User entries for mail.example.net
New user: remote-user-name
|
Either double-click or press the <Enter> key
Enter your password on the remote server.
Fetchmail user remote-user-name querying mail.example.net dialogue
Authentication
Password: *******
|
Enter the username you use to log into the local host (your computer).
Local names New name: local-user |
Delete remote-user-name since there is no such local user.
remote-user-name delete |
Save and exit in reverse order.
Fetchmail user remote-user-name querying mail.example.net dialogue OK Fetchmail host mail.example.net dialogue OK fetchmail configurator dialogue Save fetchmail launcher Quit |
Check the result by looking in ˜/.fetchmailrc. The last line should look like this:
poll mail.example.net with protocol POP3 user 'remote-user-name' there with password '*******' is 'local-user' here |
![]() | Collect your email before testing |
---|---|
It is wise to download all your email before going on. Using your existing email client software. It is possible that some email may be lost during testing if something goes wrong. |
It is time to send yourself another email. Compose it in and send it from evolution as before. (See the section on testing Evolution's configuration.) fetchmail should receive it a little while later and forward it to your local-user's local mailbox /var/mail/local-user. You can check this by looking in /var/mail/local-user or by using the mail command at the command prompt. (See the section on local mail.)
$ fetchmailconf |
fetchmail launcher dialogue
Test fetchmail
|
The fetchmail launcher dialogue opens a 'fetchmail run window' so that you can monitor the process.
fetchmail run window
Running fetchmail -d0 -v --nosyslog
fetchmail: 5.9.11 querying mail.example.net (protocol POP3) ...
...
fetchmail: couldn't find canonical DNS name of mail.example.net
...
fetchmail: normal termination, status 11
Done.
Exit
|
fetchmail launcher dialogue
Test fetchmail
|
This is what you get when everything is working properly but you have no mail to collect.
fetchmail run window
Running fetchmail -d0 -v --nosyslog
fetchmail: 5.9.11 querying mail.example.net (protocol POP3) ...
...
fetchmail: POP3< +OK ...
...
No mail for remote-user-name at mail.example.net ...
...
fetchmail: normal termination, status 1
Done.
Exit
|
If you do have mail to collect, the 'fetchmail run window' will say so.
Send yourself (local-user) a message from evolution with the subject 'Fetchmail test1'. You saw how to do this in the section on testing Evolution's configuration.
Run fetchmail to collect the message.
fetchmail launcher dialogue
Run fetchmail
|
The fetchmail launcher dialogue opens a new 'fetchmail run window'.
fetchmail run window
Running fetchmail -d0
...
1 message for remote-user-name at mail.example.net (993 octets).
reading message remote-user-name at mail.example.net:1 of 1 (993 octets)
flushed
Done.
Exit
|
fetchmailnot only checks for mail, it also downloads it to your local mailbox and flushes (deletes) it from the remote server.
$ mail Mail version 8.1.2 01/15/2001. Type ? for help. "/var/mail/local-user": 1 message 1 new >N 1 local-user@local-host Wed Feb 04 12:11 14/394 Fetchmail test 1 & q $ |
![]() | Leave evolution's other settings unchanged |
---|---|
You only need to change the way evolution receives mail. evolution will continue to send out-going mail directly to the remote SMTP server. |
In the section on configuring Evolution, you configured evolution to collect mail directly from the remote mail server. fetchmail does this job now and saves the mail locally in /var/mail/local-user. What you really want is for the email to end up in evolution again. To do this you must reconfigure evolution to retrieve the mail from /var/mail/local-user.
Run evolution. If you have several accounts, temporarily disable all but one account. You can modify the configuration of other accounts, or install new ones, when you have got the whole installation running satisfactorily.
Menu bar Tools Mail Settings ... Mail Settings dialogue Accounts |
Select an account to be disabled and disable it.
Disable OK |
(Repeat, if necessary, until only one account is enabled.)
Edit the one remaining account to change the server type from 'POP' to 'Local delivery' from /var/mail/local-user.
Menu bar Tools Mail Settings ... Mail Settings dialogue Accounts |
Make sure that the active account is selected, the edit it.
Edit |
Change the details for server type.
Evolution Account Editor dialogue Receiving Mail tab Server Type: Local delivery Configuration Path: /var/mail/local-user OK Mail Settings dialogue OK |
$ mail local-user Subject: test 2 This is a one-line message. ctrl-D Cc: ctrl-D Cc: $ $ |
Now fetch the message from /var/mail/local-user using evolution.
Button bar
Send / Receive
|
Look in evolution's Inbox to check that the mail has arrived.
Menu bar File Go to Folder ... Go to folder ... dialogue Inbox OK |
The fetchmailconf launcher allows you to run fetchmail by clicking on the Run fetchmail button (see the section on sending and receiving from a remote server). This is not very convenient for everyday use. However, you may have noticed that the Run fetchmail button invokes the command fetchmail -d0. The '-d' switch means 'run fetchmail as a daemon'. A daemon is 'a program which runs for an extended period' ... 'in the background, usually unnoticed' (see the the Linux Dictionary). The fetchmail -d command works because you installed the fetchmail daemon when you installed fetchmail as a system-wide service in the section on installing Fetchmail.
# /etc/init.d/fetchmail restart Restarting mail retrieval agent: system-wide fetchmail not configured. |
poll mail.example.net with protocol POP3 user 'remote-user' there with password '*******' |
Leave the defaults unchanged - only batchlimit is uncommented.
batchlimit 100 |
Change owner to user fetchmail and group to root.
![]() | Security |
---|---|
Notice that the password is not encrypted. The /etc/fetchmailrc file must belong to the special user fetchmail, and be readable and writeable only by owner fetchmail. |
# chown --verbose fetchmail:root /etc/fetchmailrc ownership of `/etc/fetchmailrc' retained as fetchmail:root |
Set permissions to read and write only for owner.
# chmod --verbose 0600 /etc/fetchmailrc mode of `fetchmailrc' changed to 0600 (rw-------) |
The settings in this file override those in /etc/fetchmailrc.
![]() | Security Running as root risks remote boot exploits. Make sure that RUNASROOT is set to false. |
SERVICE=true CONFFILE=/etc/fetchmailrc RUNASROOT=false |
Modify the 'options' settings to suit your needs. For example, to run fetchmail in daemon mode polling every 30 seconds specify --daemon 30. To redirect status and error messages emitted to the system logger (syslog(3)) specify --syslog.
OPTION="--daemon 10 --syslog" |
Stop the fetchmail daemon. You must be the root user to do this.
$ su Password: ******* # /etc/init.d/fetchmail stop Stopping mail retrieval agent: fetchmail. |
You will get an error if you have an incorrect configuration.
Stopping mail retrieval agent: system-wide fetchmail not running.) |
# /etc/init.d/fetchmail start Starting mail retrieval agent: fetchmail. # exit $ |
You will get an error if you have an incorrect configuration.
Starting mail retrieval agent: fetchmail (failed!) |
The most likely cause of an error is a mistake in either /etc/fetchmailrc or /etc/default/fetchmail.
Once the daemon is running, sent yourself a test mail from evolution via the remote server. Connect to your provider's server, just as you did when testing Evolution's configuration, compose and send the message.
Compose a message dialogue
To: remote-user-name@example.net
Subject: Fetchmail daemon test1
Send
|
Give the message a couple of minutes to reach the remote server and to be returned. Keep an eye on your modem lights and you should see the regular polling of mail.example.net and the email downloading to /var/mail/local-user. Retrieve the message using evolution's Send / Receive button.
Button bar
Send / Receive
|
(Repeat as necessary.)
Hopefully, everything works correctly. evolution downloads messages just as before.
X-Spam-Flag: YES |
This is how you start procmail. Put a hidden file called procmail in the user's root home directory. The presence of this file causes procmail to start and to follow any instructions contained in the procmail configuration file. procmail will run spamassassin if .procmailrc contains these two lines.
:0fw | spamassassin |
The next step is to set up a filter in evolution. The filter will move all messages with an X-Spam-Flag set to a folder called Spam instead of the normal inbox.
Menu bar Tools Filters Filters dialog Incoming Filter rules (New) Edit Rule dialog Rule name: Move to Spam folder If box Specific header X-Spam-Flag contains YES Then box Move to folder Click here to select a folder New Create new folder dialog Folder name: Spam Folder type: Mail Specify where to create the folder: Inbox OK OK |
Menu bar Tools Filters Filters dialog Incoming Filter rules Add Edit Rule dialog Rule name: Move to local folder If box Recipients contains @local-host Then box Move to folder Click here to select a folder New Create new folder dialog Folder name: Local Folder type: Mail Specify where to create the folder: Inbox OK OK |
Copyright ©2004 Chris Lale <feedback.chrislale@coolscience.co.uk>. Permission is granted to copy, distribute and/or modify this document with no Invariant Sections, with no Front-Cover texts and with no Back-Cover Texts under the terms of the GNU Free Documentation License, version 1.1 or any later version, published by the Free Software Foundation. A copy of the license can be found at http://www.fsf.org/copyleft/fdl.html.
You can get the latest version of this document from http://newbiedoc.sourceforge.net.
If you find any errors, omissions etc, please let me know via the newbieDoc Discussion list <newbiedoc-discuss@lists.sourceforge.net> or <chrislale@users.sourceforge.net>.
You can find guides to English spelling, punctuation and grammar at http://www.cral.ac.uk/guidelines/.
my-file.txt my-directory /my-path/my-directory/ my-application my-package This is some terminal text. |
Filenames, application names, package names and text displayed in an X window look like this.
my-file.txt my-application my-package This is some text in an X window. |
The Linux Documentation Project's online Linux dictionary at http://www.tldp.org/LDP/Linux-Dictionary/html/index.html(online) or linux dict http://www.tldp.org/guides.html (download).
The manual page of the System Logger. Enter the command man 3 syslog at the command prompt.
An article in the online Linux Journal at http://www.linuxjournal.com/modules.php?op=modload&name=NS-lj-issues/issue46&file=2516s2
(Osamu Aoki) Chapter 9 “Tuning a Debian system” includes brief notes about exim, fetchmail and procmail at http://qref.sourceforge.net/
Install the exim-doc package, then view the files in /usr/share/doc/exim.Start by looking at /usr/share/doc/exim/oview.txt with a text editor or viewer. Alternatively, install the exim-doc-html package, then view the file in /usr/share/doc/exim/manual.html/oview.html with a web browser.
(Oohara Yuuma). This newbieDoc article describes how to configure Exim for local use. http://newbiedoc.sourceforge.net/networking/exim.html
Information about the “Debianisation” of exim is held in the file /usr/share/doc/exim/README.Debian.
- X monitor for the exim mail transport agent.
(Oohara Yuuma) This newbieDoc article describes how to configure fetchmail. http://newbiedoc.sourceforge.net/networking/fetchmail.html