nmh-workers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nmh-workers] When a message goes only to me, as a cc


From: Paul Fox
Subject: Re: [Nmh-workers] When a message goes only to me, as a cc
Date: Tue, 11 Oct 2016 11:23:29 -0400

address@hidden wrote:
 > I usually have a line, 'address@hidden', in my drafts. I do that instead of
 > something like 'fcc: inbox', because I want to see what my Email looks like
 > after it has gone through the net. But sometimes I forget to otherwise 
 > address
 > the message. But then send will just go ahead and send the message, instead 
 > of
 > balking, as it would if I used fcc instead of cc.
 > 
 > Is there a workaround that problem?

i do this using a wrapper for my editor program -- it runs some checks
on the draft (flags missing To: header, multiple From: headers, and
reports all Attach: headers) and emits stern warnings if something's
amiss.  they appear just above the whatnow prompt, and usually i
notice them.  :-) (in the past i've had code in there to force
confirmation, but that's disabled now.)  i also use it to check
that i'm not replying to an employer domain from a personal address.

i'm afraid it never occurred to me to use scan(1) to examine the draft,
so in the grand tradition of too many choices, i use grep, whom,
formail, and sed.  bad paul.  no donut.  i'll post my script here,
because i always learn something when ralph corrects my scripts.  ;-)

paul

final_checks()
{
    draft=$1
    if egrep -q '^(To:|Resent-To:)[[:space:]]*$' $draft ||
        ! egrep -q '^(To:|Resent-To:)' $draft
    then
        echo
        echo "ERROR: missing or empty 'To:' header...."
        return 1
    fi

    numfroms=$(sed -n -e '/^\(From:\|Resent-From:\)/p' -e '/^$/q' $draft |
        wc -l)
    if [ $numfroms != 1 ]
    then
        echo
        echo "ERROR: must have exactly one 'From:' header.  (has $numfroms)"
        return 1
    fi

    if am_pgf
    then
        tolap=$(whom $draft | grep ' at laptop\.org')
        fromfox=$(formail -c -x From: < $draft | egrep '@foxharp\.')
        if [ "$tolap" -a "$fromfox" ]
        then
            echo
            echo "WARNING!!!! message is 'To: laptop' and 'From: foxharp'"
        fi
    fi

    attachments=$(sed -n -e '/^Attach:/p' -e '/^$/q' $draft)
    if [ ! "$attachments" ]
    then
        echo No attachments
    else
        if echo "$attachments" | grep -q "Attach: [^/]"
        then
            echo "$attachments"
            echo "(pwd is $PWD)"
        else
            echo "$attachments"
        fi
    fi
    return 0
}


=----------------------
paul fox, address@hidden (arlington, ma, where it's 51.8 degrees)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]