Appendix 1

  Appendix 1
2.2.11 Mail Server

     2.2.1.1 Sendmail(for delivering mail)
     2.2.1.2 Fetchmail(for fetching mail from remote servers)
     2.2.1.3 Popper(for giving the pop service to our local hosts)


2.2.1.1 Sendmail


     Sendmail is bundled with the FreeBSD, so it gets up by default. But if you are interested in running the latest version of sendmail(which is a good idea for security reasons) you can get it always from www.sendmail.org. Get the source in tar.Z format and detarr it.


maple@junan:/tmp/SENDMAIL{1013}% ls -l
total 1802
-rw-r--r-- 1 junan bin 1063534 Feb 2 13:04 sendmail.8.9.2.tar.gz
maple@junan:/tmp/SENDMAIL{1014}% cat sendmail.8.9.2.tar.gz | gunzip | tar xfv -
maple@junan:/tmp/SENDMAIL{1015}% ls -l
total 1803
drwxr-xr-x 14 junan bin 512 Feb 15 14:52 sendmail-8.9.2
-rw-r--r-- 1 junan bin 1063534 Feb 2 13:04 sendmail.8.9.2.tar.gz
maple@junan:/tmp/SENDMAIL{1016}% cd sendmail-8.9.2
maple@junan:/tmp/SENDMAIL/sendmail-8.9.2{1017}%


Read the README files available, all the necessary information should be available in them. Here is an illustration:


maple@junan:/tmp/SENDMAIL/sendmail-8.9.2{1017}% cd src
maple@junan:/tmp/SENDMAIL/sendmail-8.9.2/src{1018}% more README
maple@junan:/tmp/SENDMAIL/sendmail-8.9.2/src{1019}% sh Build
maple@junan:/tmp/SENDMAIL/sendmail-8.9.2/src{1020}% make install


Sure it will complain since you are not permitted to install in proper places as an average user. So, su to root and use make install. That's all you need to do to install this sendmail.
Ok, now we have installed sendmail properly, let's try to make it's configuration file as necessary for our server. Making a sendmail.cf file with bare editors is quite impossible so there are few packages available to make the configuration file. We will demonstrate here using the CF package available from the ftp site: ftp://ftp.kyoto.wide.ad.jp/pub/mail/CF or http://www.wide.ad.jp/~motonori/sendmail.html#CF. Most probably you will get a package named CF-3.6W.tar.gz.


maple@junan:/tmp/SENDMAIL{51}% cat CF-3.67.tar.gz | gunzip | tar xfv -
maple@junan:/tmp/SENDMAIL{52}% cd CF-3.7W
maple@junan:/tmp/SENDMAIL{53}% make tools
maple@junan:/tmp/SENDMAIL{54}% make samples
maple@junan:/tmp/SENDMAIL{55}% cp Standards/sendmail-v8.def maple.def


Now let's edit maple.def with an editor you are most familiar with.


------------------------ maple.def -----------------------
CF_TYPE=R8V8
#line added by Junan not necessary
DEF_ID='Configured on maple by Junan'
# [ostype]
# OS type (choose a file name in ostype directory)
# line added by Junan
OS_TYPE=bsd4.4
# FreeBSD based on this kernel
# [acceptaddr]
# addresses which should be accepted as local
##ACCEPT_ADDRS='$m' # can be used with R8 sendmail
# line added by Junan
# that's the address that should be regarded as local
ACCEPT_ADDRS='inf.yatsushiro-nct.ac.jp'
# [another_addr]
# define another smtp/uucp mailer which uses another address
##ANOTHER_ADDRESS=another.address
# line added by Junan
ANOTHER_ADDRESS='titan.yatsushiro-nct.ac.jp'
#line added by Junan
REWRITE_MYNAME_TO_ANOTHER_ADDRESS=yes
REWRITE_ACCEPT_ADDRS_TO_ANOTHER_ADDRESS=yes
# [indirect]
# for indirect delivery
# domain names to be deliverd directly (all/none/"domain names")
#DIRECT_DELIVER_DOMAINS=all
# line added by junan
# other than this address other addresses will be forwarded to
# smtp, set at the DEFAULT_RELAY
DIRECT_DELIVER_DOMAINS='.maple.inf.yatsushiro-nct.ac.jp'
# mailer for direct delivery
#DIRECT_DELIVER_MAILER=smtp
# relay host for indirect delivery (in case of none or "domain names")
##DEFAULT_RELAY='smtp:relay.host.name'
# line added by Junan
# it's our school mail server
DEFAULT_RELAY='smtp:titan.yatsushiro-nct.ac.jp'
------------------------ end of maple.def file -----------------------


Now when we are finished with the file let's make the .cf file:


maple@junan:/tmp/SENDMAIL/CF-3.7W{60}% make maple.cf
MASTERDIR=Master TOOLDIR=Tools Tools/Configure maple.def > maple.cf.tmp
mv -f maple.cf.tmp maple.cf


It should be working now but unfortunately you might need to add the following lines in the maple.cf(later copied to /etc/sendmail.cf):


------- Lines to change in maple.cf file --------
# don't forget to disable the previously declared Macros
Dwmaple.inf.yatsushiro-nct.ac.jp
Djmaple.inf.yatsushiro-nct.ac.jp
DSst.yatsushiro-nct.ac.jp
------- End of changes in maple.cf file --------


Now before copying it to the /etc directory give some try to the created file with the sendmail:


maple@junan:/tmp/SENDMAIL/CF-3.7W{1100}% sendmail -bt -C./maple.cf
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
>/parse junan
Cracked address = $g
Parsing envelope recipient address
rewrite: ruleset 3 input: junan
..................... omitted
rewrite: ruleset 4 input: junan
rewrite: ruleset 4 returns: junan
mailer local, user junan
> /parse junan@maple
Cracked address = $g
Parsing envelope recipient address
rewrite: ruleset 3 input: junan @ maple
rewrite: ruleset 96 input: junan < @ maple >
rewrite: ruleset 96 returns: junan < @ maple . ant . yatsushiro-nct . ac . jp >
rewrite: ruleset 3 returns: junan < @ maple . ant . yatsushiro-nct . ac . jp >
rewrite: ruleset 0 input: junan < @ maple . ant . yatsushiro-nct . ac . jp >
........................ omitted
rewrite: ruleset 4 returns: junan
mailer local, user junan
> /parse junan@maple.inf.yatsushiro-nct.ac.jp
Cracked address = $g
Parsing envelope recipient address
rewrite: ruleset 3 input: junan @ maple . inf . yatsushiro-nct . ac . jp
rewrite: ruleset 96 input: junan < @ maple . inf . yatsushiro-nct . ac . jp >
rewrite: ruleset 96 returns: junan < @ maple . ant . yatsushiro-nct . ac . jp >
rewrite: ruleset 3 returns: junan < @ maple . ant . yatsushiro-nct . ac . jp >
rewrite: ruleset 0 input: junan < @ maple . ant . yatsushiro-nct . ac . jp >
rewrite: ruleset 4 input: junan
rewrite: ruleset 4 returns: junan
mailer local, user junan
> /parse s96281@st.yatsushiro-nct.ac.jp
Cracked address = $g
Parsing envelope recipient address
rewrite: ruleset 3 input: s96281 @ st . yatsushiro-nct . ac . jp
rewrite: ruleset 96 input: s96281 < @ st . yatsushiro-nct . ac . jp >
rewrite: ruleset 96 returns: s96281 < @ st . yatsushiro-nct . ac . jp >
rewrite: ruleset 3 returns: s96281 < @ st . yatsushiro-nct . ac . jp >
rewrite: ruleset 0 input: s96281 < @ st . yatsushiro-nct . ac . jp >
rewrite: ruleset 88 input: < smtp : titan . yatsushiro-nct . ac . jp > . s962
81 < @ st . yatsushiro-nct . ac . jp >
rewrite: ruleset 88 returns: $# smtp $@ titan . yatsushiro-nct . ac . jp . $: s
96281 < @ st . yatsushiro-nct . ac . jp >
rewrite: ruleset 0 returns: $# smtp $@ titan . yatsushiro-nct . ac . jp . $: s
96281 < @ st . yatsushiro-nct . ac . jp >
rewrite: ruleset 2 input: s96281 < @ st . yatsushiro-nct . ac . jp >
rewrite: ruleset 2 returns: s96281 < @ st . yatsushiro-nct . ac . jp >
rewrite: ruleset 41 input: s96281 < @ st . yatsushiro-nct . ac . jp >
rewrite: ruleset 21 input: s96281 < @ st . yatsushiro-nct . ac . jp >
rewrite: ruleset 21 returns: s96281 < @ st . yatsushiro-nct . ac . jp >
rewrite: ruleset 41 returns: s96281 < @ st . yatsushiro-nct . ac . jp >
rewrite: ruleset 4 input: s96281 < @ st . yatsushiro-nct . ac . jp >
rewrite: ruleset 4 returns: s96281 @ st . yatsushiro-nct . ac . jp
mailer smtp, host titan.yatsushiro-nct.ac.jp., user s96281@st.yatsushiro-nct.ac
.


The last test shows that it will forward the mail to smtp which happens to be our school mail host: titan.yatsushiro-nct.ac.jp changing the from header as necessary. Let's try to send some mail and let's try to see the how the headers look like:


maple@junan:/tmp/SENDMAIL/CF-3.7W{1101}% mail junan
Subject: From Junan
Testing from maple.
The from header should be from localhost.
Give a look at the header.
maple@junan:/tmp/SENDMAIL/CF-3.7W{1103}% mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/mail/junan": 2 messages 2 new
>N 1 junan Mon Feb 15 15:40 14/394 "testing....."
& top
Message 1:
From junan Mon Feb 15 16:32:02 1999
Received: (from junan@localhost)
by maple.inf.yatsushiro-nct.ac.jp (8.9.2/3.7W) id QAA24325
for junan; Mon, 15 Feb 1999 16:32:01 +0900 (JST)
Date: Mon, 15 Feb 1999 16:32:01 +0900 (JST)
From: Junan <junan>


Let's try to a remote host:


maple@junan:/tmp/SENDMAIL/CF-3.7W{1104}% mail s96281@st.yatsushiro-nct.ac.jp
Subject: From maple
Testing from maple.
Look at the from header.

.


s96281@st.yatsushiro-nct.ac.jp is my school address. There should be a mail in that account from maple. Let's login to the account and try to find out:


mercury-gw:s96281:/home2/s96281{206}% mail
Mail version SMI 4.0 Mon Nov 21 20:47:48 JST 1994 Type ? for help.
"/usr/spool/mail/s96281": 2 messages 7 new 10 unread
N 1 c6ohuddi@tokuyama.ac.jp Mon Feb 15 13:30 114/4807 Re: From Junan
N 2 junan@st.yatsushiro-nct.ac.jp Mon Feb 15 16:38 20/950 From maple
& top 2
Message 2:
From junan@st.yatsushiro-nct.ac.jp Mon Feb 15 16:38:20 1999
Received: from titan.yatsushiro-nct.ac.jp (titan.yatsushiro-nct.ac.jp [202.251.3
2.2])
by st.yatsushiro-nct.ac.jp (8.8.8/3.6W-10/26/98) with ESMTP id QAA01719
for <s96281@mailhost.st.yatsushiro-nct.ac.jp>; Mon, 15 Feb 1999 16:38:20
+0900 (JST)
Received: from maple.inf.yatsushiro-nct.ac.jp ([202.251.39.12])


So, it's working!.

| Home | Introduction | An Overview of Our Network | System Administration | Security | Conclusion | Acknowledgements | References | Appendix 1 | Appendix 2 | Appendix 3 | Appendix 4 | Appendix 5 | Appendix 6 | Appendix 7 | Appendix 8 | Appendix 9 | Appendix 10

This page is maintained by:
jchakma@yahoo.com