Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Aug 2009 15:44:04 -0700
From:      Chris Cowart <ccowart@rescomp.berkeley.edu>
To:        Gary Kline <kline@thought.org>
Cc:        FreeBSD Mailing List <freebsd-questions@FreeBSD.ORG>
Subject:   Re: script to send out a dozen letters?
Message-ID:  <20090817224403.GD51584@hal.rescomp.berkeley.edu>
In-Reply-To: <20090815234920.GA9094@thought.org>
References:  <20090815234920.GA9094@thought.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--G3juXO9GfR42w+sw
Content-Type: multipart/mixed; boundary="8/pVXlBMPtxfSuJG"
Content-Disposition: inline


--8/pVXlBMPtxfSuJG
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Gary Kline wrote:
> if there are tools to do this, please point me at them, but i
> want to send out a snail and/or email|HTML|whatever to a handful
> of companies that i hope to find online.
>=20
> I'm guessing the inside address would me something like
>=20
> Company Name
> Address
> Company Email
>=20
> Attn Mr. Smith:
>=20
> [my canned letter]
>=20
>=20
> i forget if the inside address is before the recipient
> address--I *think* so.   is there a way of having date output
> the format "15 August, 2009" rather than my usual, 15aug09?
>=20
> I am pretty sure these people are most accustomed to GUI/html=20
> mail, so is there a way of invoking evo with html capability?
>=20
> if there are web pointers on this, puleeze clue me in!

Here's a script I whipped up a year or two ago that sends out e-mails.
You could definitely tweak it to find/replace a LaTeX template and send
it directly to the printer (circa the `| sendmail` line). See the
included readme (excuse the twiki formatting). While it was written for
bash, it may run under /bin/sh (but I make no claims).

It's really straightforward. I would die a little inside if it were used
to send HTML e-mail, but there's nothing to stop you from writing HTML
(by hand) into the template (or saving a message out of your GUI MUA of
choice into a flat file and using that as your template).

--=20
Chris Cowart
Network Technical Lead
Network & Infrastructure Services, RSSP-IT
UC Berkeley

--8/pVXlBMPtxfSuJG
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=automail
Content-Transfer-Encoding: quoted-printable

#! /bin/bash

if [ -z "$1" ] || [ -z "$2" ] || [ "x$1" =3D=3D "x--help" ]; then
    printf "Usage:\n\t${0} data_file template_file [cc1 [cc2 ... ]]\n"
    exit 1
fi

data=3D"$1"
shift
template=3D"$1"
shift

exec 0<${data}

read line

FIELDS=3D"$(echo $line | tr ';' ' ')"

while read line ; do
    column=3D1
    SCRIPT=3D""
    email=3D""
    for field_title in $FIELDS ; do
        datum=3D$(echo "$line" | cut '-d;' "-f${column}")
        SCRIPT=3D"${SCRIPT:+${SCRIPT};}s:$field_title:$datum:"
        column=3D$(($column + 1))
        if [ "$field_title" =3D "EMAIL" ] ; then
            email=3D"$datum"
        fi
    done

    printf "Mailing %s... " "$email"
    sed "$SCRIPT" "$template" | sendmail "$email $@" || {=20
        echo "Something error happened" ; continue; }
    printf "Success!\n"

done

--8/pVXlBMPtxfSuJG
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=README
Content-Transfer-Encoding: quoted-printable

---+ Overview
The =3Dautomail=3D script allows you to send templated e-mails to a list of
recipients. This is particularly useful during hiring.

---+ Usage
The =3Dautomail=3D script is installed on hal.=20

---++ The Data File
You must prepare a file with the data that will be used to fill in the
templates.

The first line of this file includes the case-sensitive field names,=20
separated by semi-colons. Each subsequent line is a data record. One e-mail
will be sent for each data record in the file.

*Example:*

<verbatim>
EMAIL;LNAME;FNAME;FOOD
ccowart@rescomp.berkeley.edu;Cowart;Chris;Bananas
keenanp@rescomp.berkeley.edu;Keenan;Parms;Ice Cream
jeremydw@rescomp.berkeley.edu;Jeremy;Weinstein;Rabbit Food
</verbatim>

Call this file ~/email_data.

*Note:* The only column title with special meaning is "EMAIL" and it *must*
appear in the data file. All other columns follow brain-dead substitutions
and do not affect the behavior of the automailer.

---++ The Template File
Here, you compose your e-mail. Note you must conform to RFC822 (Here's a
summary of the relevant points):
   * You must include the To, From, Cc, and Subject headers.
   * Headers must be properly formatted (=3DName: Contents Can Have Spaces=
=3D)
   * The headers end with a blank line. There must be a blank line before
     you begin your message.

*Example:*

<verbatim>
=46rom: The Party Planning Committee <ppc@rescomp.berkeley.edu>
To: FNAME LNAME <EMAIL>
Subject: The Potluck

Hello FNAME,

Please remember to bring FOOD to the potluck.

Thanks,

The Party Planning Committee
</verbatim>

Call this file ~/email_template.

*Note:*=20
   * Column titles (see The Data File section) will be substituted with the
     current record's column contents. The address in the EMAIL column will
     receive a copy of the message.=20
   * Including a Cc or Bcc header in the template will *NOT* affect who
     receives a copy of the message.

*Warning:* The recipient will receive the message AS-IS.=20
__Bcc Headers will not be filtered__.

---++ Sending the Message

After you declare the data file and template file (in that order), you may
add e-mail addresses to the command line (e.g., hiring@rescomp.berkeley.edu=
).
Note that other than the recipient address, no addresses (Bcc or Cc) are
parsed from your message's headers. As such, if you have cc or bcc recipien=
ts,
you must declare them here. Note also that declaring recipients here does
*not* affect the To/From/Cc/Bcc headers in the actual e-mail message.

=3Dautomail ~/email_data ~/email_template cc_address1 bcc_address2=3D

--8/pVXlBMPtxfSuJG--

--G3juXO9GfR42w+sw
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (FreeBSD)

iQIcBAEBAwAGBQJKid0zAAoJEC8b9sM8ejXtiUQP/2ohDLymlOWHGp2HSTuY3yNg
+iCvtpIHUZut7uiVa6+wRuNMSWN2h5z+OtaJMTwTE5/RrA0rYxxAOCNDW+iJGxX7
kYn0/ZX7iSJI4WWdJB03o0ehSsp0JUHaj50KRXjEXNTryvy5wfjB897gQNZ83LLy
pjoOQh7kJ2Kw1QkMJGkqxT4z9mrNJEnGu2MGIHb5OHxAgzLFmo+37lX8lM8rm/kr
wjKQOwCUm76RlmrqnhngEXDL78JOp0tFofs/QqUtvx5uwqTHfYlIVLbsGKwvck5E
Yjna1ZzcZfwOJ9woyLZcs4py2XutJHCoOQSw6LbPRY01uVevbr4O4W6hcCb7ju/L
rGyHHIqv+NAA9cM8ix/yodrDRF1Sn4J4lynnRe2CsmlZwK2KiL/G0ZU1P4jbGznC
tQNn3uP7HbBbdv5kU/7prFW38gW0ZnJ69iQ4FPQoCAxNw3UiSy72sfQGYH0HK/yq
r7vOMoTRfsZmxM71wGq6c/OmiQmdeKgkIheiRvuyNhIg/nXIRGVb4VLEfbAaQ8SG
QQCQrjiu9IlU6EUsNwZNYxxxPXpn8kY04vBE5NLyI2h8uPHi6wvQUT33tTNj/Ryc
OSOsPXiR7lwIuGp3aBMp3nAX6MBF9Eb4IJO4o593aW30hZSeyNjiwGPjVQ1AfnKK
CmYIle6dLj9cQ9XT6Nsz
=aISO
-----END PGP SIGNATURE-----

--G3juXO9GfR42w+sw--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090817224403.GD51584>