Wednesday, December 8, 2010

Add multiple email addresses to plesk server

■Create a list like below.

# vi list
01@example.com,test123
02@example.com,test123
03@example.com,test123
04@example.com,test123
05@example.com,test123
06@example.com,test123
07@example.com,test123
08@example.com,test123
09@example.com,test123
10@example.com,test123

■Create mail add script in the server.

# vi mailadd.sh
#!/bin/bash

for x in `cat list`;
do
MAIL=`echo $x | cut -d , -f 1`
PASS=`echo $x | cut -d , -f 2`
/usr/local/psa/bin/mail -c $MAIL -passwd $PASS -mailbox true
done

■Check the list of email id and password.

# vi mailchk.sh
#!/bin/bash


for x in `cat list`;
do
MAIL=`echo $x | cut -d , -f 1`
PASS=`echo $x | cut -d , -f 2`

expect -c "
set timeout 60
spawn telnet 0 110
expect \"+OK\" ; send \"USER $MAIL\r\"
expect \"+OK\" ; send \"PASS $PASS\r\"
expect \"+OK\" ; send \"QUIT\r\"
expect \"+OK\" ; send \"QUIT\r\"
"
done

If everything is ok run mailadd.sh . This is the very simple way to add more email id and password at once in Plesk server.