Sendmail

> OS/2 net index <

Sendmail in batch-bestanden

De sendmail van TCP/IP 4.3 in eCS

Sendmail 8.9.3 voor OS/2


Sendmail in batch-bestanden

Met sendmail kunt u ook berichten versturen. Hier verstuur ik onder eComStation post (mail.txt) van visser.thuis naar zolder.thuis.

[H:\]sendmail -f backup@visser.thuis sjoerd@zolder.thuis < config.sys
IBM OS/2 SENDMAIL VERSION 2.04
Using Sendmail Configuration File H:\MPTN\ETC\sendmail.cf

Op zolder wordt het in de mail queue gezet.

sjoerd@zolder:~ > mailq
/var/spool/mqueue (1 request)
----Q-ID---- --Size-- -----Q-Time----- ------------Sender/Recipient------------
f4Q7pns04315 12325 Sat May 26 09:51 <backup@visser.thuis>
<sjoerd@zolder.thuis>
sjoerd@zolder:~ > /usr/sbin/sendmail -q

In pine lezen we na het flushen van de mailspool de config.sys:

Date: Sat, 26 May 2001 17:27:19 +0100
From: IBM OS/2 SENDMAIL VERSION 2.03 <sjoerd@visser.thuis>

SET COPYFROMFLOPPY=1
REM ###################################

Nu lijkt het op het eerste gezicht wat onzinnig om de config.sys via sendmail op de opdrachtregel te backuppen, maar als er staat:

[H:\]sendmail -f klus@visser.thuis root@zolder.thuis < klus.log

dan begrijpt u dat u uzelf (en anderen) logbestanden kunt mailen van karweitjes die met cron in de automatische piloot werden uitgevoerd. Zo doen de Linux daemonen het ook. Met een pop3 checker zou u uw zoontje op gezette tijden aan tafel kunnen roepen. Of uzelf een keer per maand met een standaardtekst te manen een echte backup te maken.

Ook mag het duidelijk zijn dat u nooit zomaar op een cmd bestand moet klikken. Wie weet worden uw wachtwoorden gemaild naar een hacker.

De sendmail van TCP/IP 4.3 in eCS


#########################################################################

# #

# Sendmail #

# Copyright (c) 1983 Eric P. Allman #

# Berkeley, California #

# #

# Copyright (c) 1983 Regents of the University of California. #

# All rights reserved. The Berkeley software License Agreement #

# specifies the terms and conditions for redistribution. #

# #

# This configuration file was created specifically for sendmail on the #

# IBM OS/2 Operating System. Please avoid making changes to this file #

# because any changes will change the operation of sendmail. #

# #

# Created by: William Chung for IBM Ultimedia Mail/2 "Lite" #

# and IBM NR/2 #

# IBM T.J. Watson Research Center, Hawthorne, NY #

# #

# March 21, 1995 #

# #

# Change activity: #

# 2/96 TAB Added F=F to mLocal, changed version number #

# 3/96 TAB Added Prog definition. #

#########################################################################



#

# This configuration file routes outgoing mail as follows:

#

# 1. If mail is destined for a directly connected domain and

# an internal gateway is defined, then deliver to the gateway.

#

# 2. If mail is destined for a directly connected domain and

# no internal gateway is defined, then deliver directly.

#

# 3. If mail is destined for a domain which is not directly

# connected, then deliver to an external gateway.

#

# 4. If mail is destined for a domain which is not directly

# connected and an external gateway is not defined,

# then deliver directly.

#

# 5. In all cases, rewrite the sender address to look like

# it came from a mail hub if a mail hub is defined.

#

# 6. In all cases, deliver addresses destined for the local host

# directly with no routing through gateways.

#



#

# Macro Definitions

#

# Note: The values of the V and H macros are merely placeholders.

# Actual values will get substituted later at send time when

# sendmail is invoked with the -oM command line flag to override

# these configuration file values.

#

# The V and H macros should normally not be changed here.

#


# The fully qualified (with domain) name of the internal gateway

#

# All mail destined for the domains defined in macros D through G

# will be sent to this gateway machine

#

# If this macro is not defined, then all mail destined for the domains

# defined in macros D through G will be delivered directly

# DRYour.Internal.Gateway


# The fully qualified (with domain) name of the external gateway

#

# All mail destined for domains _not_ defined in macros D through G

# will be sent to this gateway machine

#

# If this macro is not defined, then all mail destined for domains

# _not_ defined in macros D through G will be delivered directly

# DVYour.External.Gateway


# The fully qualified (with domain) name of the external mail hub

#

# All sender addresses for external destination addresses will be

# rewritten to look like they came from this mail hub

# DHYour.External.Mail.Hub


# The fully qualified (with domain) name of the internal mail hub

#

# All sender addresses for internal destination addresses will be

# rewritten to look like they came from this mail hub

# DIYour.Internal.Mail.Hub


# External user id

#

# The user id used for sending mail through the external gateway

#

# All sender addresses for external destination addresses will be

# rewritten to look like they came from this user id

# DPYourExternalUserID


# The local domain

#

# The domains defined in macros D through G are considered internal and

# directly connected. Mail destined for these domains will be delivered

# to an internal gateway defined in macro R

#

# If macro R is undefined, then mail for internal destinations will be

# delivered directly

DDYour.Domain


# Internal, directly connected domains

#

# The domains defined in macros D through G are considered internal and

# directly connected. Mail destined for these domains will be delivered

# to an internal gateway defined in macro R

#

# If macro R is undefined, then mail for internal destinations will be

# delivered directly

DE

DF

DG


# Version # of this file TAB

DZ2.0


# Official canonical hostname.

#

# Do not bother setting macro $w (hostname) since sendmail will set

# it for us

#

# Note: We assume $w contains the fully qualified name of the local host

Dj$w






# Sendmail configuration file *must* end with a newline - do not remove below newline


De laatste zin niet vergeten!




Sendmail 8.9.3 voor OS/2

De bij OS/2 Warp 4 client geleverde sendmail versie 2.0 versie is sterk verouderd. De configuratie geschiedt via de Tab Sendmail van het TCP/IP configuratie (LAN). Deze automatische manier van configureren is eenvoudig, maar de mogelijkheden zijn zeer beperkt.

Voor de sendmail versie 8 geldt het omgekeerde. De configuratie kan bijzonder complex zijn. Maar een eenvoudige opzet voldoet op een thuisnetwerk.

U kunt lid worden van de OS/2 Sendmail mailing list via : mailto:os2-sendmail-request@eyup.org?body=subscribe. Algemene informatie is te vinden op www.sendmail.org. I



Op ftp sites als LEO zijn binaries van sendmail versie 8 te vinden. Ze maken gebruik van de emx (Emulate UNIX) bibliotheek. De ports die ik zag waren incompleet, maar bruikbaar. U kunt de bestanden met lange namen op een HPFS schijf kwijt. Ik koos voor \emx\usr\bin, maar de lokatie doet er verder niet toe. Er is ook een scriptje om WPS objecten te installeren (zie afbeelding). Maar de paden klopten niet helemaal (even aanpassen dus). Voor het configureren is het wel handig reflecties van de door u gebruikte scripts in de Sendmail map te plaatsen.

Sendmail versie 8 configureren

Het centrale configuratiebestand sendmail.cf8 wordt d.m.v. macro's aangemaakt. Het is niet de bedoeling het bestand zelf te bewerken. U moet een sjabloon van een master configuration bestand (*.mc) uitkiezen en eventueel enige macro variabelen aan uw situatie aanpassen.

De macro's bevatten variabelen, die steeds weer terug komen. Door variabelen centraal in de macro's op te slaan wordt u een hoop werk bespaard. De marco's worden door een m4 macro processor tot het uiteindelijke configuratiebestand gesmeedt. Voor de techniek hierachter zie o.a. een artikel in linux Focus: Het maken van tekstbestanden met m4 macro's .

De makro \cf\ostype\os2.m4 bevat de door OS/2 gebruikte paden en bestanden. Waarschijnlijk moet u de hier genoemde mail queue directory aanmaken. Maar u kunt ook een andere definieren. Let wel op het gebruik van de UNIX namen.

# define(`LOCAL_MAILER_PATH', /tcpip/os2pops/popsmail.exe)dnl

# define(`LOCAL_MAILER_ARGS', /tcpip/os2pops/popsmail.exe $u)dnl

define(`LOCAL_MAILER_PATH', /tcpip/bin/mail.exe)dnl

define(`LOCAL_MAILER_ARGS', /tcpip/bin/mail.exe $u)dnl

define(`ALIAS_FILE', /mptn/etc/sendmail/aliases)dnl

define(`QUEUE_DIR', /mptn/etc/sendmail/mqueue)dnl

define(`STATUS_FILE', /mptn/etc/sendmail.st8)dnl

define(`HELP_FILE', /mptn/etc/sendmail.hf8)dnl

define(`LOCAL_SHELL_PATH', cmd.exe)dnl

define(`LOCAL_SHELL_ARGS', `cmd.exe -c $u')dnl

define(`confCW_FILE', /mptn/etc/sendmail/sendmail.cw8)dnl

Het bestand \tcpip\os2pops\popsmail.exe ken ik niet. Het leek me een vervanger van het postprogramma mail.exe, gezien de volgende ingangen in sendmail.cf van OS/2:

Mlocal, P=f:\tcpip\bin\mail.exe, F=lsmDFP, S=10, R=0, A=f:\mptn\etc\mail $u

Ik heb het daarom vervangen. De m4 makro van sendmail versie 8 maakte er dit van:

Mlocal, P=/tcpip/bin/mail.exe, F=lsDFMAw5:/|@qrmn9, S=10/30, R=20/40,

T=DNS/RFC822/X-Unix,

A=/tcpip/bin/mail.exe $u

Deze waarden worden aangeroepen via het mc bestand:

OSTYPE(os2)dnl

Als uitgangpunt voor onze sendmail.cf8 nemen generic-os2.mc uit de templates map (\cf\cf\). Deze slaan we onder een nieuwe naam (sjoerd-os2.mc) op. De extensie MC staat voor master configuration. Hieronder staat de relevante inhoud uit generic-os2.mc.

divert(0)dnl

VERSIONID(`@(#)generic-os2.mc 8.8 (Berkeley) 1/25/98')

OSTYPE(os2)dnl

DOMAIN(generic)dnl

MAILER(local)dnl

MAILER(smtp)dnl

MAILER(uucp)dnl

FEATURE(use_cw_file,/mptn/etc/sendmail/sendmail.cw)

FEATURE(domaintable,hash -o /mptn/etc/sendmail/domaintable)

FEATURE(genericstable,hash -o /mptn/etc/sendmail/genericstable)

FEATURE(access_db,hash -o /mptn/etc/sendmail/access)

FEATURE(mailertable,hash -o /mptn/etc/sendmail/mailertable)

FEATURE(virtusertable,hash -o /mptn/etc/sendmail/virtusertable)

FEATURE(uucpdomain,hash -o /mptn/etc/sendmail/uucpdomain)

FEATURE(always_add_domain)

SITECONFIG(agro2,uucp.agro2.dp.ua,U)

FEATURE(blacklist_recipients)

Met de FEATURE macro's (bijv. \cf\feature\nocanonify.m4)worden benodigde eigenschappen toegevoegd. undefine ('functie') doet het omgekeerde en laat een functie of eigenschap weg. Zoals u ziet verwijzen veel FEATURES naar tekstbestanden in \mptn\etc\sendmail.

OSTYPE geeft het besturingssysteem aan.

Dit gedeelte passen we aan:

divert(0)dnl

VERSIONID(`@(#)sjoerd-os2.mc (Zwolle) 1/10/00')

# Sendmail draait onder OS/2

OSTYPE(os2)dnl

DOMAIN(generic)dnl

SITECONFIG(sjoerd-visser.demon.nl,visser.thuis,U)

MAILER(local)dnl

MAILER(smtp)dnl

FEATURE(use_cw_file,/mptn/etc/sendmail/sendmail.cw)

FEATURE(access_db,hash -o /mptn/etc/sendmail/access)

FEATURE(always_add_domain)

FEATURE(blacklist_recipients)

FEATURE(masquerade_envelope)

FEATURE(nocanonify)

MASQUERADE_AS(sjoerd-visser.demon.nl)

define(`SMART_HOST',smtp:post.demon.nl)dnl

undefine('UUCP_RELAY')

undefine('BITNET_RELAY')


Het volgende cmd-scriptje gaf deze output. Het is een bewerking van Sendmail-8.9.3\OS2\makecf.cmd.

@echo off

cls

echo.

echo Generating SENDMAIL.CF8

echo.

cd ..\cf

..\os2\m4 ./m4/cf.m4 domain/generic.m4 ./cf/sjoerd-os2.mc > ..\os2\sendmail.cf8

cd ..\os2

copy f:\mptn\etc\sendmail.cf8 f:\mptn\etc\sendmail.old

copy ..\os2\sendmail.cf8 f:\mptn\etc\sendmail.cf8

---------------------------

Generating SENDMAIL.CF8


SYS0003: Het systeem kan het opgegeven pad niet vinden.

./m4/cfhead.m4:20: ..\os2\m4: Cannot open /tmp/cfa00113: No such file or directo

ry

SYS1041: Naam rm is geen interne of externe

opdracht of is geen programma of batch-bestand.

*** ERROR: FEATURE(blacklist_recipients) requires FEATURE(access_db)

1 bestand(en) gekopieerd.

1 bestand(en) gekopieerd.

De eerste foutmelding kan genegeerd worden. Rm is het onder OS/2 afwezige UNIX verwijder commando, hoewel je ook een rm.cmd met del%1 zou kunnen aanmaken.

FEATURE(access_db,hash -o /mptn/etc/sendmail/access)

werd toegevoegd en het aangepaste makecf.cmd werd opnieuw gedraaid. Daarna werd Sendmail configuratie in daemon modus (sendmail \bd) gestart. Als hier foutmeldingen verschijnen is er meestal iets misgegaan met de macro bestanden.

Sendmail is een mail router en de post moet naar de juiste bestemming worden doorgesluisd. De configuratie wordt uitgetest met "Test Configuration" (sendmail -bt).