How to send a message to a list

  1. 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.
  2. 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.

  3. 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; he throws all his mail away.)

  4. Get a shell and run the following command: /var/qm/bin/mjinject addressfile < messagefile where addressfile is the list, is the return address (for the inevitable bad addresses), and messagefile is the file containing your message.
  5. 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:
    Amanda Green;;cYVPqudA
    Barney Google;;zqaVV0VI
    Clara Verde;;hi948iiU
    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:
    while read line
      name="`echo $line | cut -d\; -f1`"
      addr="`echo $line | cut -d\; -f2`"
      pw="`echo $line | cut -d\; -f3`"
      cat <<EOF | mailx -s "your new password" $addr
    Hi $name!
    Your new password is $pw so don't lose it!
      echo mailed to $addr
      sleep 1
    done < datafile
    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
    sh ./dothis
    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.