This is a tutorial on how to install Mailman on a VPS with a DirectAdmin control panel installed on it.
Mailman is a free software for managing electronic mail discussion and e-newsletter lists.
To install it, execute the following commands:
cd /usr/local/src /usr/sbin/useradd -r -s /bin/false mailman mkdir /usr/local/mailman chown mailman:mailman /usr/local/mailman chmod 02775 /usr/local/mailman wget http://ftp.gnu.org/gnu/mailman/mailman-2.1.15.tgz tar xzf mailman-2.1.15.tgz cd mailman-2.1.15 ./configure --with-cgi-gid=apache make make install chmod 755 /usr/local/mailman/cgi-bin chmod u-s,g-s /usr/local/mailman/cgi-bin/* chmod 777 /usr/local/mailman/logs chown -R mailman:mailman /usr/local/mailman chown nobody:mailman /usr/local/mailman/logs/error /usr/local/mailman/bin/newlist -q -e your-hostname.com mailman mailman@your-hostname.com your_password
Please do not forget to change ‘your_password’ and ‘your-hostname.com’ accordingly.
Edit your ‘/etc/exim.conf’ Exim configuration file and add the following lines:
Before primary_hostname add:
MAILMAN_HOME=/usr/local/mailman MAILMAN_WRAP=MAILMAN_HOME/mail/mailman
After begin routers add:
mailman_router: driver = accept require_files = MAILMAN_HOME/lists/$local_part/config.pck local_part_suffix_optional local_part_suffix = -bounces : -bounces+* : \ -confirm+* : -join : -leave : \ -owner : -request : -admin transport = mailman_transport
After begin transports add:
mailman_transport:
driver = pipe
command = MAILMAN_WRAP \
'${if def:local_part_suffix \
{${sg{$local_part_suffix}{-(\\w+)(\\+.*)?}{\$1}}} \
{post}}' \
$local_part
current_directory = MAILMAN_HOME
home_directory = MAILMAN_HOME
user = apache
group = apache
Add the following lines to your ‘/etc/aliases’ file:
mailman: "|/usr/local/mailman/mail/mailman post mailman" mailman-admin: "|/usr/local/mailman/mail/mailman admin mailman" mailman-bounces: "|/usr/local/mailman/mail/mailman bounces mailman" mailman-confirm: "|/usr/local/mailman/mail/mailman confirm mailman" mailman-join: "|/usr/local/mailman/mail/mailman join mailman" mailman-leave: "|/usr/local/mailman/mail/mailman leave mailman" mailman-owner: "|/usr/local/mailman/mail/mailman owner mailman" mailman-request: "|/usr/local/mailman/mail/mailman request mailman" mailman-subscribe: "|/usr/local/mailman/mail/mailman subscribe mailman" mailman-unsubscribe: "|/usr/local/mailman/mail/mailman unsubscribe mailman"
Then, execute the following commands:
newaliases /usr/local/mailman/bin/config_list -i /usr/local/mailman/data/sitelist.cfg mailman
Create an init script:
vi /etc/init.d/mailman
#!/bin/sh
#
# mailman This shell script starts and stops GNU Mailman.
PYTHON=/usr/bin/python
MAILMANHOME=/usr/local/mailman
MAILMANCTL=$MAILMANHOME/bin/mailmanctl
SRC_CRON_SCRIPT=$MAILMANHOME/cron/crontab.in
DST_CRON_SCRIPT=/etc/cron.d/mailman
function InstallCron()
{
install -m644 -o root -g root $SRC_CRON_SCRIPT $DST_CRON_SCRIPT
}
function RemoveCron()
{
cat > $DST_CRON_SCRIPT <<EOF
# DO NOT EDIT THIS FILE!
#
# Contents of this file managed by /etc/init.d/mailman
# Master copy is /usr/local/mailman/cron/crontab.in
# Consult that file for documentation
EOF
}
# Source function library.
. /etc/rc.d/init.d/functions
RETVAL=0
prog="mailman"
function start()
{
echo -n $"Starting $prog: "
daemon $PYTHON $MAILMANCTL -s -q start
RETVAL=$?
if [ $RETVAL -eq 0 ]
then
touch /var/lock/subsys/$prog
InstallCron
fi
echo
return $RETVAL
}
function stop()
{
echo -n $"Shutting down $prog: "
daemon $PYTHON $MAILMANCTL -q stop
RETVAL=$?
if [ $RETVAL -eq 0 ]
then
rm -f /var/lock/subsys/$prog
RemoveCron
fi
echo
return $RETVAL
}
function restart()
{
stop
start
RETVAL=$?
return $RETVAL
}
case "$1" in
'start')
start
RETVAL=$?
;;
'stop')
stop
RETVAL=$?
;;
'restart')
restart
RETVAL=$?
;;
'condrestart')
$PYTHON $MAILMANCTL -q -u status
retval=$?
if [ $retval -eq 0 ]
then
restart
RETVAL=$?
fi
;;
'status')
$PYTHON $MAILMANCTL -u status
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart}"
;;
esac
exit $RETVAL
Execute the following commands:
chmod 755 /etc/init.d/mailman chkconfig --add mailman
Edit the ‘mm_cfg.py’ file:
vi /usr/local/mailman/Mailman/mm_cfg.py
DEFAULT_EMAIL_HOST = 'mail.your_domain.com'
DEFAULT_URL_HOST = 'www.your_domain.com'
IMAGE_LOGOS = '/mailman_images/'
add_virtualhost(DEFAULT_URL_HOST, DEFAULT_EMAIL_HOST)
VIRTUAL_HOSTS = {'www.your-domain.com': 'your-domain.com'}
Add the following line to the ‘/etc/httpd/conf/httpd.conf’ Apache configuration file:
Include conf/extra/mailman.conf
Create a ‘mailman.conf’ configuration file (change ‘Your_IP_address’ with your actual IP):
vi /etc/httpd/conf/extra/mailman.conf
Alias /mailman_images/ /usr/local/mailman/icons/ Alias /mailman/archives/ /usr/local/mailman/archives/public/ Alias /pipermail/ /usr/local/mailman/archives/public/ ScriptAlias /mailman/ /usr/local/mailman/cgi-bin/ RedirectMatch ^/mailman[/]*$ http://Your_IP_address/mailman/listinfo
Create a ‘.htaccess’ file:
vi /usr/local/mailman/.htaccess
AuthName "Mailman" AuthType Basic AuthUserFile /usr/local/mailman/cgi-bin/.htpasswd require valid-user
Create a ‘.htpasswd’ file:
cd /usr/local/mailman/cgi-bin/ touch .htpasswd
htpasswd -c .htpasswd mailman
Restart your Exim and Apache services for the changes to take effect and start the Mailman service:
/etc/init.d/exim restart /etc/init.d/httpd restart /etc/init.d/mailman start
That’s it. You should be able to create a new mailing list by entering the relevant information at:
https://Your_IP_address/mailman/create username: mailman password: your_password
Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install this for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.
