Powered by Invision Power Board


  Reply to this topicStart new topicStart Poll

> Sendmail client HOWTO
dancave
  Posted: Jun 13 2003, 02:37 PM
Quote Post


User Level: 2
**

Group: Members
Posts: 28
Member No.: 47
Joined: 13-June 03



Client Sendmail HOWTO.
----------------------

Daniel Cave, 19th April 1997. Version 1.0a

This document is intended to explain some of the finer points about
sendmail & how you I wrote the 'client.cf' sendmail config file to forward
mail from clients on clan net to the mailhub (mercury) aka
hippos.demon.co.uk.

The client.cf file is included in this document for reference

1.How client.cf was written

I constructed this cf file to send all outboud internet/local email to
the mailhub, in conjuction with the O'Reilly Sendmail book, written by
Brian Costales & Eric Allman.
This book starts off by identifing the basic concepts of sendmail and
how the beast works.

There are a number of details that you will need to know about for
sendmail.

o Different versions of sendmail (especially v 8.7.x & 8.8.x) have
*slightly* different configuration options in them, so the level
of compatablilty between v 8.7.4 & 8.8.4 cf files could quite
significant, so don't expect the client.cf file to work with versions
of sendmail below 8.8.0.

(like the option macro 'O'. In version 8.8.x there is a space
between the O and the option definition, whereas in v8.7.x there
isn't a space)

e.g.

O QueueDirectory=/var/spool/mqueue(v 8.8.x)

or

OQueueDirectory=/var/spool/mqueue(v 8.7.x)

This sort of thing can be fixed quite simply removing the space
between the 'O' and the first character of the new option. But
other options and macro definitions might cause sendmail to
die/hang.

o In order to enable email to be delivered to the mailhub you must
have DNS running so that sendmail can perform lookups to resolve
hostnames & IP addresses of machines on the network & the mailhub.

o Make sure that you have an up to date version of sendmail on your
mailhub and your client machines. I reccommend that you use the
8.8.5 version src code and build the binary from that. A pgp signed
key is available from ftp://ftp.sendmail.org/ to authenticate the
version doesn't contain any nasties.

How the cf file works.
######################

There are 5 basic rule sets that sendmail internally deals with.

Ruleset Purpose
-------------------------------------------------------------------------------

0Defines which mail delivery agent you want to use.
1 Contains & re-writes the origin of the senders email
address.

2 Contains & re-writes the destination of the senders email
address.
3 The originating source of the email address (contains
rulesets 0,1 & 2)

4 The outbound email message that has been processed by
rulesets 1 & 2, also contains extra headers from other
rulesets within sendmail.

As we're not too concerned with extra flashy features that sendmail can
handle, the client cf contains some of the standard rulesets, these will
be explained later.

To start off with we need to define some custom macros that contain the
names of our mailhub (internally & externally). These macros will enable
our custom ruleset 'HUBSET' to process mail by sendmail a client and
re-write the 'from' headers to make the message appear as if it originated
from the mailhub, then forwarding the mail onto the mailhub to be
delivered to its destination.

These macros are defined like so.

D{NAME_OF_MACRO} MACROS_VALUE

You will see from the cf file that our two macros are defined in the
following manner.

D{REMOTE}mercury # name of the mail hub on the internal
# network
D{HUB}hippos.demon.co.uk # name of the mail hub to the internet

You can have as many custom defined macros as you wish. These may also be
re-definitions of existing macro values that sendmail knows about.

You can find out the internal macro values that sendmail knows about, by
running sendmail in test mode (-bt) and debug level 0.1.

This will tell you about the internal features that are built into the
version of sendmail that you have when you compiled the source code.

% ./sendmail -bt -d0.1 < /dev/null

Version 8.8.5
Compiled with: LOG MATCHGECOS MIME7TO8 MIME8TO7 NAMED_BIND NETINET
NETUNIX QUEUE SCANF SMTP XDEBUG

============ SYSTEM IDENTITY (after readcf) ============
(short domain name) $w = denifs
(canonical domain name) $j = denifs.demon.co.uk
(subdomain name) $m = demon.co.uk
(node name) $k = denifs.demon.co.uk
========================================================

You can re-define these values by adding them in as macros in the cf file.

Next step is to specify which options (Sendmail options, Headers and Mail
precedence) you want to use.

(These were copied from a standard sendmail.cf file and compared against
the options reccommended in the sendmail book for the client cf file to
prevent options that were not required.)

When these options have been setup, you will need to configure the
delivery agents,

#Delivery agent definition to forward mail to hub
Mhub, P=[IPC], S=Hubset, R=0, F=xmDFMuXa, T=DNS/RFC822/SMTP,A=IPC $h
Mlocal, P=/bin/mail, F=lsDFMAw5:/|@rmn, S=0, R=0, A=mail -d $u

The P & S options state which rulesets to use for the [R]eply & [S]enders
field.

The options against the 'F=' option are message field header flags that
are inserted into the mail message such as date, full name of recipient,
Reply-to: fields.

The next section deceides how the cf file interpets the mail from the
recipients MTA, error handling and the re-writing of the recipients
address.

How the rulesets work.
######################

Ruleset 0
#########


Ruleset 0 handles the error checking part of a recipient's address. If the
recipient is missing from the address body, the internal error handling
mechanism of sendmail will return the mail to its originator, specifing
the nature of the error. If the address is o.k, then sendmail forwards the
mail onto the mailhub, using the value contained in the macro {REMOTE},
which in our case happens to be mercury, the mailhub on our LAN.

#Define new rules
S0 # ruleset 0
R@$+ $#error $: Missing user name
R$+ $#hub $@${REMOTE} $:$1 forward to hub

Ruleset 3
#########

Ruleset 3 is rather tricky to understand unless you know what the
parameters mean. Basically this ruleset looks for any nested addresses
like '<daniel <dan> cave>' or double nesting.


S3 # Ruleset 3, Preprocessing for all rulesets
R$* <> $* $n handle <> error addres

R$* < $* < $* > $* > $* $2<$3>$4 de-nest nested brackets
R$* < $* > $* $2 basic RFC822 parsing

Ruleset Hubset
##############

This ruleset is the actual rule that rewrite the recipients address to
make the mail message appear that it came from the mailhub rather from the
client.

SHubset # Rewrite the sender for the hub
R$- $@ $1@${HUB} user -> user@hub
R$-@$=w $@ $1@${HUB} user@local -> user@hub
R$-@$w.${HUB} $@ $1${HUB} #user@local.host.co.uk ->
# user@hub

All this ruleset says, if I get 'dan' as the from address input, then
rewrite the address as dan@hippos.demon.co.uk

or

if address = dan@host (which value is stored in $w) $w is the logical
hostname that the hostname client that the cf file is running on.

NEW..

I have added a new rule to the Hubset ruleset to handle some newer
versions of sendmail which add the hostname to the FQDN after it. This is
especially true if you're running DNS where the localhost/mailhub is the
DNS server and the originating mail comes from one of these machines.

Where the address would read:

dan@onehost.fully-qualified.domainname.co.uk

The extra rule would rewrite the address change it to

dan@fully-qualified.domainname.co.uk

S1 # Generic sender rewrite (unused )

This isn't used.

Problems

1.Mail programs hang for a period of time when mail is being sent.

Remedy.

o Make sure that your DNS server is running correctly,
If you compiled sendmail with the DNS_BIND option

o Check your /etc/hosts file.

o Stop/Restart named.


2.mailq hangs for ages....

oCheck that you have got the correct name of the your mailhub in
the client.cf for your LAN

Daniel Cave.

-------------------------------------
client.cf
----------- cut here ----------------
######################################################################
######################################################################
#####
##### SENDMAIL CONFIGURATION FILE
#####
##### built by daniel@mercury on Mon Mar 10 17:42:33 GMT 1997
##### in /usr/src/sendmail/cf
#####
##### Appended 24/4/97.
##### Added new rule to ruleset Hubset to handle host.host.name.co.uk
##### conversion.
#####
######################################################################
######################################################################

##### @(#)cf.m48.4 (Berkeley) 12/24/93 #####

##### linux for smtp-only setup #####
##### @(#)linux.m48.2 (Berkeley) 8/21/93 #####

#### @(#)nouucp.m48.1 (Berkeley) 6/7/93 #####

##### @(#)always_add_domain.m4 8.1 (Berkeley) 6/7/93 #####


##### @(#)proto.m48.45 (Berkeley) 3/4/94 #####

#CLIENT SENDMAIL CF FILE for CPL.

# level 5 config file format
V5

#Locally defined Macros
D{REMOTE}mercury# name of the mail hub on the internal net
D{HUB}hippos.demon.co.uk# name of the mail hub to the internet

Cwlocalhost# other names to which this host is associated with
Fw -o /etc/sendmail.cw # file that sendmail accepts as Class w.

# Options
O QueueDirectory=/tmp # REMEMBER, Use /var/spool/mqueue on release
O Timeout.queuewarn=4h # set queue timeout warning
O Timeout.queuereturn=5d
O DeliveryMode=background
O TempFileMode=0600
O DefaultUser=1:1
O LogLevel=9
O OldStyleHeaders=True
O BlankSub=.# Replace unquoted spaces with .

#Headers
HFrom: <$g># added if it's missing
HReceived: by $j; $b# always put this field in.
H?x?Full-Name: $?x$x$. # Insert fullname if avail.
H?D?Date: $a# Add if F=D
H?M?Message-Id: <$t.$i@$j># Add if F=M

# Precedence
Pspecial-delivery=100
Pfirst-class=0
Plist=-30
Pbulk=-60
Pjunk=-100

#Delivery agent definition to forward mail to hub
Mhub, P=[IPC], S=Hubset, R=0, F=xmDFMuXa, T=DNS/RFC822/SMTP, A=IPC $h
Mlocal, P=/bin/mail, F=lsDFMAw5:/|@rmn, S=0, R=0, A=mail -d $u

#Define new rules
S0# ruleset 0
R@$+$#error $: Missing user name
R$+$#hub $@${REMOTE} $:$1 forward to hub

S3# Preprocessing for all rulesets
R$* <> $*$nhandle <> error addres
R$* < $* < $* > $* > $* $2<$3>$4de-nest nested brackets
R$* < $* > $* $2basic RFC822 parsing

SHubset # Rewrite the sender for the hub
R$- $@ $1@${HUB} user -> user@hub
R$-@$=w $@ $1@${HUB} user@local -> user@hub
R$-@$w.${HUB} $@ $1@${HUB} # user@host.domainname ->
# user@hub
S1 # Generic sender rewrite (unused)
PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
« Next Oldest | Tutorials & How-To's | Next Newest »

Topic Options Reply to this topicStart new topicStart Poll

 



[ Script Execution time: 0.0461 ]   [ 12 queries used ]   [ GZIP Enabled ]




Partners: Cambridge Plus :: <Link Available> :: 3D Mechanical Design :: <Link Available>
Unix Man Pages / Linux Man Pages :: HiFi Forum :: SIP VoIP Phone & Provider Reviews :: UNIX/Linux Forum Archives

More info on advertising on Unix/Linux Forum