I have a server running Debian Woody with Postfix, Courier IMAP and Squirrelmail. The server runs fine but I want to be able to automate the creation of users.
When I started, creating virtual user account was a bit of a process so I wrote a script that took care of most of it. Here is the script I am using:
______________________________________________________________
#
#Script to create virtual user for email account
#
echo "Enter the username:"
read uname
maildirmake /home/vmail/Maildir-$uname
chown vmail /home/vmail/Maildir-$uname
userdb "$uname" set home=/home/vmail mail=/home/vmail/Maildir-$uname uid=1002 gid=100
userdbpw | userdb "$uname" set imappw
makeuserdb
echo $uname@mydomain.com Maildir-$uname/ >> /etc/postfix/vmailbox
postmap /etc/postfix/virtual
postmap /etc/postfix/vmailbox
postfix reload
chown -R vmail /home/vmail/Maildir-$uname
chgrp -R users /home/vmail/Maildir-$uname
_______________________________________________________________
This works just fine. It asks me to enter the username and then I have to enter the password twice. I would like to be able to set this to automatically run when one of my users signs up for email.
The only thing that is getting in my way is that it asks me for a password. I would like to designate the password in the script. I have read a few sites that say I can do that by changing my "userdbpw" line to this:
userdbpw | userdb "$uname" set imappw=password
Where "password" is the password I want to give to the user. That great except that it doesn't work.

It still asks me for the password. If I cancel out when it asks me for the password and then check out the /etc/courier/usedb file the correct password shows up but it doesn't work when I try to log in. All the others that were created the default way seem to be encrypted but the one where I used imappw=password is just plain text.
Does anyone know what I need to do to get this to work?
Sorry for the long post. Thanks for the help!
Hawkpaul