How to set up a mail list so that you can email ALL of your domains at one time

From QmailToaster
Jump to navigation Jump to search

Have you ever wanted to email all the user accounts on all domains on your server at the SAME time (server downtime notifications, etc)? Now you can and the best part is that it is very simple to do!

The first thing you need to do is to create a mailinglist on your default domain (does not have to be the default domain, however usually this is your domain anyway). I would suggest making the name of the list something obtuse (not easy to guess so as to prevent spam) and also set it so that only moderators can post (another spam stopping trick).

Once you have set up your mailing list, copy the script below into a file called "list-create.sh". Put this file into your /etc/cron.daily directory

# vi /etc/cron.daily/list-create.sh
#!/bin/sh
# script name: list-create.sh
# function: delete member and re-subscribe existing email accounts on all domain
# in your server into a mailing list for public announcement
#
# 06/15/2010 - Scott Hughes <scott@renshawauto.net>
# Initial creation of script to create an import text file of all
# users on system and then import it into an already created
# ezmlm mailing list.
#
# 04/16/2011 - Scott Hughes <scott@renshawauto.net>
# Added the complete removal of list subscribers before list
# generation to take care of deleted accounts. Thanks to Pak Ogah
# for the idea.
#
# 04/19/2011 - PakOgah <PakOgah@pala.bo-tak.info>
# Use variables for mailing list name
# Name of your mailinglist
mailinglist="mylist@mydomain.com"
# Do not edit codes below:
echo "All user mailing list generation..."
# Separate domain and listname
listname=${mailinglist%@*}
domainname=${mailinglist#*@}
# Deleting current subscribers from mailing list
rm -f /home/vpopmail/domains/$domainname/$listname/subscribers/*
# Generate mailing list import file
#/home/vpopmail/bin/vpopbull -n -V > ~/alluserslist.txt
# Import List into ezmlm mailing list
~vpopmail/bin/vpopbull -n -V | ezmlm-sub ~vpopmail/domains/$domainname/$listname
exit 0

Then change the permissions so that it is executable:

#chmod +x /etc/cron.daily/list-create.sh

That's all you have to do. When the script runs it will first delete all the current subscribers and then re-create them from the domains and users on your server.

Enjoy!