Current time: 12-22-2024, 10:14 PM Hello There, Guest! (LoginRegister)


Post Reply 
add email account script
Author Message
calocen Offline


Posts: 4
Joined: May 2007
Reputation: 1
Post: #1
add email account script
I hope this bash script will be useful for people, like me, who are migrating from another panel solutions.

To use the script download and rename it from .txt to .sh

please notify some bug.


.txt  ispcp_add_email.sh.txt (Size: 2.4 KB / Downloads: 236)
(This post was last modified: 01-03-2008 04:24 AM by calocen.)
01-03-2008 02:59 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Zothos Offline
Release Manager
*****
Dev Team

Posts: 1,262
Joined: Feb 2007
Reputation: 10
Post: #2
RE: add email account script
no file XD
01-03-2008 03:56 AM
Find all posts by this user Quote this message in a reply
mafia Offline
Banned

Posts: 170
Joined: May 2008
Post: #3
RE: add email account script
Hello, first thanks a lot

Can I ask if this script is still
updated at this time?ispCP 1.0.5
05-11-2010 04:09 AM
Find all posts by this user Quote this message in a reply
Alien85 Offline
Newbie
*

Posts: 8
Joined: Nov 2010
Reputation: 0
Post: #4
RE: add email account script
Thank you for add email account script!

Script for delete email:
Code:
#!/bin/bash
# by alien.ru@mail.ru from by calocen@gmail.com (ispcp_add_email.sh)
# ver.: 1.0
# 25/11/2010
# remove email account in a control panel structure with default config
# parameters:
# 1: email_account@domain.tld where (aliases not deleted)
# 2: [rebuild]: if true, then do a rebuild of rqst-orders

DEBUG="true"

# syntax control
if [ $# -lt 1 ] ; then
    echo -e "\n\nSyntax: "
    echo -e "\t $0 <name@domain.tld>"
    exit 01
fi
cEmail=$1
[ -z $2 ] && bRebuild="false"
[ ! -z $2 ] && bRebuild="true"
$DEBUG && echo $bRebuild
cAcc=`echo $cEmail | cut -f1 -d"@"`
cDom=`echo $cEmail | cut -f2 -d"@"`

# check if domain exists and get domain Id
nDomID=$(mysql ispcp -ss -u ispcp_mails -pMYPASSWORD -n -e "SELECT domain_id FROM domain WHERE domain_name='$cDom';")

if [ -z $nDomID ]
then
    echo -e "\n\n $cDom not exists, please add it before add email accounts"
    exit 02
fi

# Check if email accounts exists
nMailID=$(mysql ispcp -ss -u ispcp_mails -pMYPASSWORD -n -e "SELECT mail_id FROM mail_users WHERE domain_id='$nDomID' AND mail_acc='$cAcc';")
$DEBUG && echo -e "nDomID:$nDomID\tcDom:$cDom\tcAcc:$cAcc"
if [ -z $nMailID ]
then
    echo -e "\n\nE-Mail account is not exists"
    echo -e "\nnDomID:$nDomID\tcDom:$cDom\tcAcc:$cAcc"
    exit 03
fi

# remove email record in mail_users table
cSql="DELETE FROM mail_users WHERE mail_id='$nMailID' LIMIT 1;"
$DEBUG &&  echo -e "$cSql"
mysql ispcp -u ispcp_mails -pMYPASSWORD -e "$cSql"

if [ "$?" -ne "0" ] ; then exit 1 ; fi

# rebuild virtual aliases
/usr/sbin/postmap /etc/postfix/ispcp

# rebuild mail accounts if set rebuild parameter
$bRebuild && /var/www/ispcp/engine/ispcp-rqst-mngr

rm -R /var/mail/virtual/$cDom/$cAcc

Script not deleted mailboxes in /etc/postfix/ispcp/* and /var/www/ispcp/postfix/*. Please help!
(This post was last modified: 11-25-2010 06:30 PM by Alien85.)
11-25-2010 01:05 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 2 Guest(s)