1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

How does Plesk API send data about new email accounts?

Discussion in 'Plesk for Linux - 8.x and Older' started by floatingworld, Jan 2, 2008.

  1. floatingworld

    floatingworld Guest

    How does Plesk create email accounts? Can the Plesk API "send" data about the username and password of new accounts to an external script? I am asking this because we want to use a spam filtering system that our parent company has designed, and we want make it interface with Qmail/Plesk.
  2. Amin Taheri

    Amin Taheri Golden Pleskian Plesk Certified Professional

    Jul 5, 2007
    Likes Received:
    Seattle Area
    You can set the event manager to do this kind of stuff.

    Event Types available:
    Mail account Created
    Mail account Updated
    Mail account Deleted

    You can setup a script such as /tmp/showenv.sh

    exit 0
    and set the event manager to call this script in a fashion like:
    /tmp/showenv.sh > /tmp/vars.log
    This will show you all the environment variables that are available to you. At that time if there is something that you need that you dont have, you can directly query the PSA MySQL databse to lookup anything else.

    #Get LoginPW for Plesk DB
    admin_pwd=`cat /etc/psa/.psa.shadow`
    #In this example, NEW_DOMAIN_NAME is part of the environemnt from the event
    #Get the Domain Name's owner from MySQL based on the odmain name
    mysql="mysql -N -B -uadmin -p$admin_pwd psa"
    query="SELECT c.login from clients c, domains d where c.id=d.cl_id AND d.displayName='$NEW_DOMAIN_NAME'"
    CLIENT_LOGIN=`echo "$query"|$mysql`
    #You now have their plesk LoginID in the $CLIENT_LOGIN variable
    That was just a very basic example, ubt you can basically get almost anything with that kind of combined approach.

    What I do is I use the event manager to call a SH script which invokes a PHP script becuase I want to tie in THEIR API with OUR corporate API so when domains are created, passwords updated, databases, etc we can keep track in our database as well for our billing and usage calculations - and calling an external source API is easier for me in php, but I had to use a SH script to call the php as it didnt work directly calling the php from the event manager for some reason.

    I dont see why you couldnt do something similar here