How to send a message to a list
- Read the Mail
Abuse Prevention System LLC's mailing list management guidelines.
Recall that putting people on a mailing list without their permission
in advance and sending mail to that list can get your account killed.
- Create a plain text file containing one address per line.
Each address must begin in column 1. You can add a blank and a comment
after the address, it will be ignored.
See commands for cleaning up a mailing list.
- Create a file containing the message. This file should conform
to the Standard for the Format of ARPA Internet Text Messages.
At the least, it should have valid ``From:'' and ``To:'' lines,
followed by a blank line, followed by the message body.
The whole thing should be in 7-bit ASCII. If you must use
an extended character set, MIME-encode it in quoted-printable.
The ``To:'' address will be available to all recipients, so choose
an address whose owner won't mind. (You can use
davenull@greens.org
;
he throws all his mail away.)
- Get a shell and run the following command:
where
addressfile
is the list, you@youraddress.net
is the return address (for the inevitable bad addresses),
and messagefile
is the file containing your message.
A copy of your message will be sent to each address.
Sending customized messages to a list
Okay, now let's say you want to send a different message to each person.
Suppose you have a text file (datafile
) containing names, addresses, and passwords.
They are delimited like so:
but there are a thousand of them. You want to distribute the passwords.
You can do it with a ``shell script,'' that is a program written in
the language of the shell itself. Something like this will work:
The ``EOF
'' has to begin in column 1.
It signals the end of the internal ``here'' document.
Just put the script in a file dothis
and run it by typing
How it works
The script reads a line from the datafile.
The ``cut
'' commands cut the three fields from the line
and load them into shell variables. (Notice there is no space
around the ``=
'' operators. Mandatory.)
The shell inserts the variable values into the ``here document''
and the ``mailx
'' command line.
The ``cat
'' command feeds the ``here document''
into the ``mailx
'' command.
``Mailx
'' generates and mails a message to the
address on its command line, with the subject specified with its
``-s
'' argument.
The ``sleep 1
'' pauses one second between mailings.
Do that if you have more than about 50 addresses so Qmail can get
rid of them faster than you send. The script loops until it hits
the end of the datafile.