best/easiest commandline email program for mass-email

Alex Janssen alex at
Tue Feb 2 22:55:31 UTC 2010

Thanks for your help, Hal and to everyone else, too.
This should make it easier for someone else to get a mass-mailer working.
Here's what I did:

Install mailx
sudo apt-get install mailx

I'm not sure if the next two steps are needed, but it does tell you what 
to do next.

sudo dpkg-reconfigure sendmail

Select none for configuration

You see the message:
  Postfix was not set up.  Start with
   cp /usr/share/postfix/ /etc/postfix/
   If you need to make changes, edit
   /etc/postfix/ (and others) as needed.  To view Postfix 
   values, see postconf(1).

  After modifying, be sure to run '/etc/init.d/postfix reload'.

Modifiy below.

Now, set up SMTP AUTH
Tutorial at

Quick synopsis of the above tutorial:
Create plaintext file named sasl_passwd in /etc/postfix with one line 
per login with the domain name and a login-name:password pair.
  Example:    username:userpassword

Create database file from sasl_passwd with the following command:
  postmap hash:/etc/postfix/sasl_passwd

Add the following variable definitions to
  smtp_sasl_auth_enable = yes
  smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
  smtp_sasl_security_options =
  address_verify_sender = username at

Substitute a real address for address_verify_sender.

Reload Postfix with the following command as root:
  postfix reload

My test bash script follows:

# the mail program


# Errors are sent here
SENDER="myaddress at"

# put this in a loop
MAILTO=someone at

# Do a loop for a bunch of emails from a file
# Un-comment here and below to make the loop work.
# while read MAILTO
# do

# the following section is an alteration of Hal Burgiss's suggestion on 
Ubuntu users list 1/27/2010
( echo "From: $SENDER"
  echo "To: $MAILTO"
  echo "Subject: $SUBJECT"
  echo "Reply-To: $SENDER"
  echo  "MIME-Version: 1.0"
  echo "Content-Type: text/html; charset=\"ISO-8859-1\""
  # Add required blank line to separate header/body.
  # Body goes now ...
  cat $BODYPART1
  echo $MAILTO
  cat $BODYPART2

# Pause here to keep from overloading the mail server and drawing attention
#sleep 2

# substitute your email list name after the input redirector, <
#done  < list_of_email_addresses
#      Redirecting input from end of loop does not start a sub-shell in bash
exit 0

 Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. - Albert Einstein (275)

More information about the ubuntu-users mailing list