61. How do I send bulk mail?
Use Bcc in your normal mail program
In this example we will use the webmail for sending the mail. First create a list of recipients in Excel.
Compose a mail in the webmail, Activate the Bcc-field (click on Bcc) and then copy and paste all the recpients into the Bcc-field. Put yourself in the To-field. You do not want everyone to be able to reply all to everyone receiving the mail, do you?
- Write your mail and send.
Use a mailing list at Sympa
If you wish to send to the list of persons several times you maybe want to create a mailing list on the mailing list server.
You can create a mailing list for this purpose who only you can send to. Please send a message to servicedesk@uu.se and tell them what you want. Visit the Mailing list service Sympa.
Make sure only you are allowed to send to the list.
Send the bulk mail with a script
This solution requires some basic knowledge in using a text editor like Vi, Nano, Emacs or the built in TextEdit in macOS. If you do not know how to do that then this solution is not for you.
- Put all your recipients in a file like this, one recipient on each line and call it to.txt.
jerker.nyberg.1@bmc.uu.se jerker.nyberg.2@bmc.uu.se jerker.nyberg.3@bmc.uu.se
- Create your message in a file called message.txt like
this. Change the subject and the sender address.
Subject: The subject of the mail From: persona.non.grata@example.uu.se MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=utf-8 Content-Transfer-Encoding: 8BIT Hello all, Please read this important information. Bla bla bla. Kind regards, Jerker Nyberg von Below, UU BMC
- Then create a script that does the sending. Call it bulkmail.sh. Change the sender address again.
#!/bin/bash REFILE=$1 BODY=$2 if test ! -e "$BODY" ; then echo Error file $BODY does not exist exit 5 fi if test ! -e "$REFILE" ; then echo Error file $REFILE does not exist exit 5 fi cat "$REFILE" | while read RE ; do echo Sending to $RE ( echo To: $RE cat $BODY ) | /usr/sbin/sendmail -f persona.non.grata@example.uu.se "$RE" done
Make sure the script is exacutable.
$ chmod +x bulkmail.sh $ _
-
Make sure you can send mail via the university mail server from your computer. If this is a macOS machine you want to set the replay host to smtp.uu.se. You do this by adding the following row to the file /etc/postfix/main.cf. This will only work when you are located on the Upppsala University network.
relayhost = smtp.uu.se
You may need to restart the computer after this is done.
-
Run the script like this:
$ ./bulkmail.sh to.txt message.txt Sending to jerker.nyberg.1@bmc.uu.se Sending to jerker.nyberg.2@bmc.uu.se Sending to jerker.nyberg.3@bmc.uu.se $ _