Simple Mail Transfer Protocol

advertisement
Introduction to Unix
Sendmail
Sendmail
It's been said that you aren't a real
Unix system administrator until
you've edited a sendmail.cf file.
It's also been said that you're crazy
if you've done it twice.
O’Reilly’s “Bat Book”
4th Edition -- covers Versions 8.10 through 8.14
Flying Fox
(a species of
fruit bat)
What is Sendmail?
Sendmail is the most widely used Mail Transport
Agent (MTA) on the internet
MTAs send mail from one machine to another.
Sendmail is not a client program, which you use
to read your email.
Sendmail is one of the behind-the-scenes
programs which move email over the Internet.


Normally it runs as a background daemon
Can even be run out of the super daemon (xinetd)
Implementations
SMTP Gateway



An SMTP gateway allows users on your network to
communicate with others on the Internet without
concern as to which local mail software package
exists on your network.
All incoming mail for your network will pass
through this gateway which converts the message
into the appropriate format specific to your local
mail software.
Similarly, all mail destined for the Internet from
your network will pass through this gateway to be
sent across the Internet via SMTP
Implemetations
SMTP Relay ”Warning Will Rogers”



An SMTP relay is a machine that actually sends
the mail across the Internet.
A common misconception is that SMTP gateways
are the same as SMTP relays. This is not always
the case.
There are SMTP gateways that act as relays
themselves, but there are also many that do not.
If the latter is the case on your network, you'll
need to bounce your mail off one of the relays.
The Pieces
The binary:
/sbin/sendmail
The configuration file:
/etc/mail/sendmail.cf
Supporting files:
/etc/mail/access
/etc/mail/aliases
…and many more
More Pieces
Email messages are stored in the directory:
/var/spool/mail
 There is a separate file for each user
Email waiting to be sent
./var/spool/mqueue
A log of Email sent and received:
/var/log/mail
Sendmail Features
Sendmail uses DNS (Domain Naming System)

But not 100% dependent: [Joe@[192.168.1.1]
DNS provides Mail Exchange (MX) Info
Sendmail can do a DNS double-tap

Lookup up who the client says they are
Sendmail default is “mail relay off”
Realtime Blackhole Lists (RBL)
Mail Relay checkers - - Open Mail Relay Db
http://www.ordb.org/submit/
Sendmail Anti-Spam Enhancements
Mailscanner




Minimal anti-spam
Anti-virus integration (scan in/outbound)
http://www.sng.ecs.soton.ac.uk/mailscanner/
Or http://www.mailscanner.info
Spam Assassin





Rule based heuristic
Header and text analysis
Blacklist (RBL)
Vipul's Razor (http://razor.sf.net)
http://www.spamassassin.org
Sendmail
configuration and installation
Basic configuration
Many types of configuration possible



Separate mail servers on one network
Mails forwarded to a gateway then forwarded onto
individual mail-servers
One mail server with many clients
Method Chosen:

One mail server
 Problems occur with too much load
 Overcome by load balancing through many mail servers
with same disks
 Method most chosen in sites (easier to administrate)
Concepts of sendmail
Simple installation

Mail user agent-read and compose email messages
 pine – cursor based graphical mail viewer
 mail – command line mail

Mail transport agent- accepts mail from user agent,
understand recipients address. Gets mail to correct host for
delivery
 esmtp- extended simple mail transport protocol
 Or smail, qmail, exim

Delivery agent – accepts mail from transport and delivers it to
appropriate recipients
 Mail, /bin/sh, procmail ,pop, phquery, uucp
 Mail – simple user delivery agent
Necessities
Other software needed besides sendmail
DNS server




Canonical name for local host
Looks up hosts that connect
Looks up hosts for delivery
SMTP to find the address to connect to
File System



/var/mail access inbox/spool for clients
/home to access simple files
/usr/local or software to access mail software
Checklist for DNS
mailserver

An mx record on dns
Hosts



A lookup record Name to IP
A reverse lookup record (validation purpose) IP to
Name
/etc/hosts
Compile and Configure
Compile



retrieve off of sendmail.org
untar and unzip
compile .sh Build
Configuration (m4 Macros)


Choose a configuration file matching
your os
Generic-linux.m4
m4 Configuration Files
M4 a macro preprocessor that produces a sendmail
configuration file by processing a file that ends in
.mc.
Macros used are:





define – defines a macro
undefine – discards a previous definition
include – includes a file
dnl – discards characters up to including the next new line
divert – manages output streams
Types of Configuration
OSTYPE is the operating type



Linux, sgi, solaris
Specifies directories of where files are located for normal
sendmail including queues and spool directories through
variables
Chose ostype(linux)
VERSIONID version id of the sendmail you build
More Configuration
DOMAIN allows to include domain files for site
specific information


Use generic for small sites
Large sites spam, databases, tables
MAILER delivery agent specifications.

Types:
 Local,smtp,fax,usenet,procmail…

Used
 local and smtp
 MAILER(`local’) MAILER(`smtp’)

Computer science dept:
 Procmail, local, and smtp
Even more Configuration
FEATURE


Options to change sendmail’s behavior
use_cw_file – necessary, names of all local hosts for which
this host accepts
 “whatever.com”, “mail.whatever.com”


redirect – allows forwarding
access_db – necessary, consists of ips, or domains
 Specify rejects, OK, discard or relay for machines to use smtp on that
server.
 Must use makemap hash /etc/mail/access < /etc/mail/access
No not more….. configuration

nocanonify
 Avoid dns lookups locally.
 Used for client transport agents

nullclient
 FEATURE(`nullclient’,`mail.whatever.com’)
 All mail is delivered to the mailserver
MASQUERADE_AS

allow multiple machines hide behind one single identity
 MASQUERADE_AS(`cs.umbc.edu’)
 MASQUERADE_AS(`whatever.com’)
MAIL_HUB


Automatically done
Incoming mail smtp:mail.whatever.com
SMART_HOST


Automatic with masquerade
Outgoing mail smtp:mail.whatever.com
Configuration
Server configuration







OSTYPE(`linux’)
DOMAIN(`generic’)
FEATURE(`use_cw_file’)
FEATURE(`access_db’)
MASQUERADE_AS(`whatever.com’)
MAILER(`local’)
MAILER(`smtp’)
Client configuration



OSTYPE(`linux’)
FEATURE(`nocanonify’)
FEATURE(`nullclient’, `mail.whatever.com’)
Creating cf file
Build cf file for client/server
make filename.cf
cp filename.cf /etc/mail/sendmail.cf


Client configuration is copied for client
Server configuration is copied for server
/etc/aliases
Necessary file for sendmail
System wide config file maintained by administrator

Computer Science Dept. uses email lists, and aliases for professors
Should always contain postmaster
Sendmail will not work without this file

Trust me…..
Can contain include files for lists or other interfaces to
majordomo (CS) or listproc like (OIT)



Majordomo = FREE
Listproc = expensive
Configuration for sendmail has to enable /bin/sh for majordomo or
listproc
Running Sendmail
Should be done in RC scripts
Linux has a rc file already if sendmail is installed
Kill –TERM pid to kill sendmail
/usr/sbin/sendmail -bd –q1h & to run again
mv mqueue if queue is clogged, located in
/var/spool/mqueue
Various Types of Clients with
Different Operating Systems
For each OS and version compile a new sendmail
Make sure all clients share the same version of
sendmail. Or sendmail not interact properly with
server and client
Create a new sendmail.cf file for each type of
operating system supported. Use the m4 interpreter



Solaris
Linux
Irix
Problem Solving for
Configuration
Ensure smtp is running on mail-server



telnet to hostname w/ port 25 from client
If connection refused major problem
Try from mail server as well
cd /var/log and tail messages


Make sure variables are sound and correct on start up
Make sure dns resolving and lookups are correct when mails
are received
tail maillog

Make sure no errors have been reported
More problem solving…
make sure mail is being placed into mqueue at least temporarily
directory

Also try typing mailq to see if they are not being delivered to end
user
Make sure mail is being placed in user /var/mail/username.
Simply cat out user file
Make sure you created a mail inbox in /var/mail
References
RFC’s:



RFC 821 - Simple Mail Transfer Protocol
RFC0822 - Standard for the Format of ARPA Internet Text
Messages
RFC 1521 - MIME (Multipurpose Internet Mail Extensions)
E-mail Explained

http://www.sendmail.org/email-explained.html
Download