Lets first start with what this would be used for:
Lets say you want to make a Gentoo box that handles all your e-mail, so that all your outgoing mail gets sent to your ISP's mail server, and all your incoming mail can get handled by your own spam filters on procmail or via SpamAssassin, or even just be read by Mozilla.
So we need a few things to start.
#1: Fetchmail
#2: Sendmail
#3: Procmail
#4: E-mail Client (I use pine)
so:
Code: Select all
emerge sendmail
emerge m4
emerge procmail
emerge fetchmail
First thing we want to do is to configure sendmail to accept e-mail only from the localmachine, as well as sending e-mail only through your ISP's mail server.
You need to edit the /etc/mail/sendmail.mc file to include the following:
Code: Select all
divert(-1)
#
# Copyright (c) 1998, 1999 Sendmail, Inc. and its suppliers.
# All rights reserved.
# Copyright (c) 1983 Eric P. Allman. All rights reserved.
# Copyright (c) 1988, 1993
# The Regents of the University of California. All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
#
divert(0)dnl
include(`/usr/share/sendmail-cf/m4/cf.m4')dnl
define(`confDEF_USER_ID',``8:12'')dnl
VERSIONID(`$Id: sendmail.mc,v 1.2 2002/07/04 04:55:29 g2boojum Exp $')dnl
OSTYPE(linux)dnl
DOMAIN(generic)dnl
define(`SMART_HOST',`mail.yourisp.net')dnl
MASQUERADE_AS(yourisp.net)dnl
FEATURE(`allmasquerade')dnl
FEATURE(`masquerade_envelope')dnl
define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')dnl
FEATURE(`smrsh',`/usr/sbin/smrsh')dnl
FEATURE(`local_lmtp',`/usr/sbin/mail.local')dnl
FEATURE(`local_procmail')dnl
define(`PROCMAIL_MAILER_FLAGS',`procmail -Y -m $h $g $u')dnl
define(`PROCMAIL_MAILER_ARGS',`procmail -Y -m $h $g $u')dnl
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
MAILER(procmail)dnl
MAILER(local)dnl
MAILER(smtp)dnl
Cwlocalhost.localdomain
Now that you have a sendmail.mc file you need to use the program m4 to convert it to sendmail.cf format.
Code: Select all
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
Code: Select all
/etc/init.d/sendmail start
The next thing you want to do is to make sure it only is listening on the local interface.
Code: Select all
telnet localhost smtp
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mhonline.net ESMTP Sendmail 8.12.6/8.12.6; Fri, 22 Nov 2002 11:44:56 -0500
ehlo mhonline.net
250-mhonline.net Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-DELIVERBY
250 HELP
quit
221 2.0.0 mhonline.net closing connection
Connection closed by foreign host.
Code: Select all
telnet 123.456.789.101 smtp
Trying 123.456.789.101...
telnet: Unable to connect to remote host: Connection refused
Code: Select all
rc-update add sendmail default
If you have just a few users, you can setup fetchmail with a user specific configuration file.
~/.fetchmailrc
Code: Select all
set postmaster "username"
set bouncemail
set properties ""
set daemon 300
poll mail.yourisp.net with proto POP3
user "ispusername" there with password "isppassword" is username here options fetchall warnings 3600
It also sets fetchmail to run in the background, checking your e-mail every 300 seconds (5 minutes)
The poll option tells fetchmail to poll your isp's mail server with the POP3 protocol (That can be changed to other protocol's that fetchmail supports)
Then it says that "ipsusername" has a password of "isppassword" and to deliver that username's mail to "username" on the local server.
The extra options say to fetch everything on the server and then delete the messages.
You can add more usernames to the fetchmailrc file if you wish, you would just add another user line to the ISP poll line, or if you have multiple POP/IMAP/etc accounts you can put another poll line in to do multiple servers.
Now you can run fetchmail from a shell.
Then you can access the mail however you prefer to. (Pine, Mutt, Mozilla Mail, etc)
Hope that helps someone,
Binestar
chrisf@mhonline.net



