[plug] Sendmail Is it possible to spool mail locally

Raven ian.kent at pobox.com
Sun Jun 11 16:38:41 WST 2000



James Robert New wrote:

> The idea is to avoid dial on demand, by storing the mail on the system
> somewhere till I do connect then have  automated mail sending.
> I feel that sendmail can do this.

I assume you mean you are trying to avoid sending mail causing a dialup.

My config does this. You might like to check it out and tell me which statements
are not needed or incorrect.
I also have a little script to check and send the mail, either as a forced check
(ie. will bring up the line and fetch and send mail), just a check (ie. bring up
the line and ... if mail is waiting) and check only if line is up.

They are included below.

File is called /etc/sendmail.mc:

Some points to note are:

1) Your masquerade domain is probably not pobox.com.
2) You probably don't have an internal domain called 'bogus'.
3) The LOCAL_RULE_1 is a fix for a problem with pine. I can't remember what it
fixed or where I got it, but I leave it in anyway.
4) I have not talked about address translations done by 'genericstable' and
'virtusertable' which I kindof use!

divert(-1)
dnl This is the macro config file used to generate the /etc/sendmail.cf
dnl file. If you modify thei file you will have to regenerate the
dnl /etc/sendmail.cf by running this macro config through the m4
dnl preprocessor:
dnl
dnl        m4 /etc/sendmail.mc > /etc/sendmail/cf
dnl
dnl You will need to have the sendmail-cf package installed for this to
dnl work.
include(`/usr/lib/sendmail-cf/m4/cf.m4')
define(`confDEF_USER_ID',``8:12'')
OSTYPE(`linux')
define(`confRECEIVED_HEADER', `$?sfrom $s
        $.by $w ($v/$Z)$?r with $r$. id $i$?u
        for $u; $|;
        $.$b')
# Define our userdb file for FQDN rewrites
Kuserdb btree -o /etc/mail/userdb.db
undefine(`UUCP_RELAY')
undefine(`BITNET_RELAY')
define(`confAUTO_REBUILD')
define(`confTO_CONNECT', `1m')
define(`confTRY_NULL_MX_LIST',true)
define(`confDONT_PROBE_INTERFACES',true)
define(`confDELIVERY_MODE', `delay')
define(`confDIAL_DELAY', `10s')
define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')
define(`SMART_HOST', `mail.q-net.net.au.')
dnl define(`confUSERDB_SPEC', `/etc/mail/userdb.db')
MASQUERADE_AS(pobox.com)
MASQUERADE_DOMAIN(bogus)
GENERICS_DOMAIN(bogus)
GENERICS_DOMAIN(raven.bogus)
GENERICS_DOMAIN(budgie.bogus)
GENERICS_DOMAIN(twinsen.bogus)
LOCAL_USER(root)
FEATURE(`smrsh',`/usr/sbin/smrsh')
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable')
FEATURE(`genericstable',`hash -o /etc/mail/genericstable')
FEATURE(redirect)
FEATURE(always_add_domain)
FEATURE(masquerade_envelope)
FEATURE(masquerade_entire_domain)
FEATURE(use_cw_file)
dnl FEATURE(`access_db')
FEATURE(local_procmail)
LOCAL_RULE_1
########################################################
### Local Ruleset 1, rewrite sender header & envelope ##
########################################################
#Thanks to Bjart Kvarme <bjart.kvarme at usit.uio.no>
S1
R$-                     $1 < @ $j . >                   user => user at localhost
R$- < @ $=w . > $*      $: $1 < @ $2 . > $3 ?? $1       user at localhost ?
R$+ ?? $+               $: $1 ?? $(userdb $2 : mailname $: @ $)
R$+ ?? @                $@ $1                           Not found
R$+ ?? $+               $>3 $2                          Found, rewrite

#NOTE    ^^^^^^^^^^^^^^^       ^^^^^^^^^^^^^^^^^^^^^^^^^
#         Use Tab Characters  Use Tab Characters in these regions
# to make three columns (the line with "mailname" only has 2 columns).
MAILER(procmail)
MAILER(smtp)
dnl FEATURE(`blacklist_recipients')
FEATURE(`accept_unresolvable_domains')
dnl FEATURE(`relay_based_on_MX')


File is called /etc/ppp/mail_run:

#!/bin/bash
#

MAILHOST="mail.q-net.net.au"
VERBOSE=""
RCFILE="--fetchmailrc /root/.fetchmailrc"

set -- `getopt cf $*`
for i
do
    case "$i" in
        -f)
            flag=$i; shift;;
        -c)
            flag=$i; shift;;
    esac
done

# Wait for line to come up ???
function wait_for_connect ()
{
    HOST=$1
    typeset -i SLEEP_TIME=5
    typeset -i MAX_REPEAT=10
    typeset -i REPEAT=0
    typeset -i ERR

    /bin/ping -c 1 $HOST >/dev/null 2>&1
    ERR=$?
    while [ $ERR -ne 0 ]; do
        REPEAT=`/usr/bin/expr $REPEAT + 1`
        if [ $REPEAT -gt $MAX_REPEAT ]; then
            echo "Problem with the mail host. Cannot continue."
            exit 1
        fi
        /bin/sleep $SLEEP_TIME
        /bin/ping -c 1 $HOST >/dev/null
        ERR=`/usr/bin/expr $?`
    done
}

# Always check if modem line is up
if [ -f /var/lock/LCK..modem ]; then
    /usr/sbin/sendmail -q
    /usr/bin/fetchmail --daemon 0 $VERBOSE $RCFILE $MAILHOST
    /usr/sbin/sendmail -q
    exit 0
fi

# Check if mail to send, only fetch mail if sendmail
# brings up line
if [ "${flag}x" = "-cx" ];then
    /usr/sbin/sendmail -q
    /usr/bin/fetchmail --daemon 0 -I ppp0/0 $VERBOSE $RCFILE $MAILHOST
    /usr/sbin/sendmail -q
    exit 0
fi

# Force a mail check, use fetchmail to bring up line
if [ "${flag}x" = "-fx" ];then
    wait_for_connect mail.q-net.net.au.
    /usr/sbin/sendmail -q
    /usr/bin/fetchmail --daemon 0 $VERBOSE $RCFILE $MAILHOST
    /usr/sbin/sendmail -q
    exit 0
fi



Ian K





More information about the plug mailing list