<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0051)http://www.cysonet.com/~wouter/offline_mailing.html -->
<HTML><HEAD><TITLE>Sendmail and dial-up modem internet</TITLE>
<META content="text/html; charset=windows-1250" http-equiv=Content-Type>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR></HEAD>
<BODY>
<H1>Sendmail and dial-up modem internet</H1>
<META content="Sendmail and Dialup Internet" name=description>
<META
content="sendmail , dynamic ip , genericstable , dial up
internet , smtp , rewriting headers"
name=keywords>
<H2>Introduction </H2>This document describes how to configure sendmail for
users who do not have a direct internet connection, but use a dial-up account
with an ISP to connect to the internet.
<H2>Motivations </H2>I wanted to be able to send and receive e-mail from my
linux box at home that didn't have a permanent connection to the internet.
<BR>Problems with sendmail and dial-up accounts include<BR>
<LI>Mail errors caused by sendmail trying to send messages when no internet
connection is available. Sendmail should only try to send outgoing mail if a
dial-up connection is active. Also, sendmail shouldn't complain if it can't send
messages for a few hours.
<LI>Sending mail can take a long time if the domain you are sending mail to is
far away, or has a bad connection. To resolve this problem, ISP's often offers a
SMTP server. By default, a smart-host is not used by sendmail.
<LI>Being unable to send mail because messages are refused because the local
host/domain does not exist. This is typicaly the case when a direct internet
connection is not available.
<LI>If the above is not the case, messages will appear to be sent from a machine
that doesn't exist on the internet, or from an e-mail address that is incorrect.
This is the case when the local username differs from the account name in the
e-mail address. E.g. my username at my local machine is wouter, but my e-mail
starts with hanegraa which is my account at my university's mail system. In this
case masquerade_as isp.domain.dom won't help, and will result in messages
appearing to be sent by localuser@dialup.domain, which is definitely wrong.
<UL></UL>
<H2>Instructions </H2><PAR>The solution to these problems involves configuring
sendmail and creating some additional files which sendmail will use to convert
the headers. The following will work for sendmail 8.8.7 or higher ( I am using
sendmail 8.8.7, higher versions should work also, older versions _may_ work).
</PAR><PAR>We must create a config macro file from which we can create the
sendmail.cf file. Change the <CODE>/usr/lib/sendmail-cf/cf/yourhost.m4</CODE>
file (The exact location of the cf directory may differ from your configuration)
to something like the following: </PAR><PRE>divert(0)
VERSIONID(`@(#)sendmail.mc 8.8.7 ')
OSTYPE(yourOs)dnl
FEATURE(masquerade_envelope)dnl
FEATURE(genericstable, hash -o /etc/mail/genericstable.db)
GENERICS_DOMAIN(myhost)
GENERICS_DOMAIN(myhost.mysubdomain.mydomain.dom)
GENERICS_DOMAIN(mysubdomain.mydomain.dom)
dnl # Defer Delivery to "expensive" mailers until next time the
dnl # queue is processed using "O HoldExpensive=True" and make
dnl # sure smtp mailers are "expensive".
dnl # (See original "sendmail" book Chapter 30: Options,
dnl # "Oc - Don't connect to expensive mailers", or
dnl # 2nd Edition "sendmail" book Chapter 34.8.29,
dnl # "HoldExpensive (c), Queue for expensive mailers".)
dnl # / Leif Erlingsson <LEIF@LEGE.COM>
define(`confCON_EXPENSIVE', `True')
define(SMTP_MAILER_FLAGS, e)
define(`confTO_QUEUEWARN', `16h')
define(`SMART_HOST', `mysmtp')
MAILER(local)dnl
MAILER(smtp)dnl
</PRE>The <CODE>masquerade_envelope</CODE> feature tells sendmail to rewrite not
only the headers but also the envelopes. Mailservers on the internet will look
at the envelope, and if it contains erroneous addresses, it will bounce the
message.<BR>The <CODE>genericstable</CODE> feature causes sendmail to rewrite
the from address as defined in the <CODE>/etc/mail/genericstable.db</CODE> file.
The <CODE>GENERICS_DOMAIN</CODE> lines define for which hosts/domains sendmail
should rewrite the message headers and envelopes using the genericstable. <!--(At least, that's what I believe, please
correct me if I'm wrong)--><BR>The
<CODE>define(`confTO_QUEUEWARN', `16h') </CODE>line will tell sendmail not to
complain if it isn't able to send a mail for less than 16 hours. This is useful
if you have your computer automaticly check and receive e-mail once or twice a
day. Normally sendmail starts complaining after 4 hours, which is too soon for
me.<BR>The <CODE>smarthost</CODE> line configures sendmail to use the smtp
server of our internet provider. This is not necessairy, but it can speed up
sending mail because sendmail will now transfer mail to yous isp's smtp which is
usually fast.<BR>The mailer parts make sure mail is only sent when an internet
connection is active. Otherwise, it stays in the mailqueue.<BR>Now, we are ready
to create a sendmail.cf file from the yourhost.m4 file. Cd to sendmai_cf_dir/cf
and execute the follolwing command:<BR><PRE>m4 ../m4/cf.m4 yourhost.m4 > yourhost.cf
</PRE>Make a backup of your /etc/sendmail.cf and copy yourhost.cf to
<CODE>/etc/sendmail.cf</CODE>.<BR>The last but most important part comes now:
create a file <CODE>/etc/mail/genericstable </CODE>. My genericstable file looks
like this: <PRE>wouter@duckman.sloterdijk.nl hanegraa@wins.uva.nl
wouter@duckman hanegraa@wins.uva.nl
wouter hanegraa@wins.uva.nl
</PRE>Maybe the first line suffices, but the last lines won't hurt. <PRE>makemap hash /etc/mail/genericstable.db < /etc/mail/genericstable
</PRE>After restarting sendmail, things should work now.
<H3>Testing the configuration </H3>We can test if addresses are rewritten
correctly by running sendmail in test mode: <CODE><PRE>14 wouter@duckman ~/docs 15:14 > sendmail -bt
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <RULESET> <<!-- -->address<!-- -->>
> 3,1,10,4 wouter@duckman.sloterdijk.nl
rewrite: ruleset 3 input: wouter @ duckman . sloterdijk . nl
rewrite: ruleset 96 input: wouter < @ duckman . sloterdijk . nl >
rewrite: ruleset 96 returns: wouter < @ duckman . sloterdijk . nl . >
rewrite: ruleset 3 returns: wouter < @ duckman . sloterdijk . nl . >
rewrite: ruleset 1 input: wouter < @ duckman . sloterdijk . nl . >
rewrite: ruleset 1 returns: wouter < @ duckman . sloterdijk . nl . >
rewrite: ruleset 10 input: wouter < @ duckman . sloterdijk . nl . >
rewrite: ruleset 50 input: wouter < @ duckman . sloterdijk . nl . >
rewrite: ruleset 50 returns: wouter < @ duckman . sloterdijk . nl . >
rewrite: ruleset 94 input: wouter < @ duckman . sloterdijk . nl . >
rewrite: ruleset 93 input: wouter < @ duckman . sloterdijk . nl . >
rewrite: ruleset 3 input: hanegraa @ wins . uva . nl
rewrite: ruleset 96 input: hanegraa < @ wins . uva . nl >
wins.uva.nl: Name server timeout
rewrite: ruleset 96 returns: hanegraa < @ wins . uva . nl >
rewrite: ruleset 3 returns: hanegraa < @ wins . uva . nl >
rewrite: ruleset 93 returns: hanegraa < @ wins . uva . nl >
rewrite: ruleset 94 returns: hanegraa < @ wins . uva . nl >
rewrite: ruleset 10 returns: hanegraa < @ wins . uva . nl >
== Ruleset 10,4 (10) status 75
rewrite: ruleset 4 input: hanegraa < @ wins . uva . nl >
rewrite: ruleset 4 returns: hanegraa @ wins . uva . nl
>
</PRE></CODE>If this works, we're all set! Outgoing mail will be queued but not
delivered (there's usually no internet connection so this is a good thing). So,
after connecting to the internet we have to make sure mail is sent using the
command <CODE>sendmail -q </CODE>
<H6>copyright 1999: <A href="mailto:hanegraa@wins.uva.nl">Wouter
Hanegraaff</A></H6></LI></BODY></HTML>