Not sure if this will be helpful, or if it's 100% correct, but I made this ugly script by mashing together two of Darrell's contribs. I took the script structure from his addusers script and the instructions from the virtual mail alias how-to, and created the script below. It *appears* to work. Keep in mind, I know nothing about shell scripting, other than reading thru others, and "figuring out" what they do. I used this to load about 60 mail aliases on a server, but haven't had a chance to test it live yet. Overall, the management of virtual domain mail is a dirty manual kludge, in need of a slicker way to manager it. I just cooked up a faster way to kludge a bunch of them.
#!/bin/sh
#
# USAGE:
#
# Create the file /root/vmailalias in the following format:
#
# USERNAME1:VDOMAIN1
# USERNAME2:VDOMAIN2
#
# and so on...
#
# This script will create .qmail-default files in each user's home directory,
# and set correct ownership and rights to that user.
#
################################################################################
# Make sure template fragment exists
mkdir -p /etc/e-smith/templates-custom/var/qmail/control/virtualdomains
touch /etc/e-smith/templates-custom/var/qmail/control/virtualdomains/90aliases
UFILE=/root/vmailalias
if [ ! -f $UFILE ]; then
echo User database $UFILE missing
exit
fi
# export record=cat $UFILE
# if [ "$record" != "" ]; then
for record in cat $UFILE
do
username=echo $record | awk -F":" {'print $1'}
vdomain=echo $record | awk -F":" {'print $2'}
# echo username into /userhomedir/.qmail-default
touch /home/e-smith/files/users/$username/.qmail-default
echo $username > /home/e-smith/files/users/$username/.qmail-default
# Set the ownership and rights on .qmail-default to the user only:
chown $username:$username /home/e-smith/files/users/$username/.qmail-default
chmod 644 /home/e-smith/files/users/$username/.qmail-default
# In the 90aliases file enter virtual alias in the form username@virtualdomain:username.
# In the example below info@domain1.com is to go to user fred.
# info@domain1.com:fred
echo $username@$vdomain:$username >> /etc/e-smith/templates-custom/var/qmail/control/virtualdomains/90aliases
done
# Update the /var/qmail/control/virtualdomains configuration file
/sbin/e-smith/signal-event console-save
# Restart qmail
service qmail restart
#===============================================