Email creation Integration with PLESK 7.5 Reloaded on Red Hat (php 4.* and MySQL 4.*)

Posted on 2005-04-06
Last Modified: 2010-04-21

I am trying to write a function to allow users to have an email account created in PLESK 7.5 Reloaded when they register with one of my websites. However, I can not get this very important line to work. Any help would be appreciated.  I set up the public keys and all that jazz, but it just won't work. PHP isn't in safe mode. I have tried system() exec() shell_exec() and passthrough(), no go.  I know it is possible, though.  I don't care how I get this working, whether with a shell script or php, but I need to get it to work. I am not sure if I can give more than 500 points, but I wish to give a 1000 points if possible.

Here is what I tried, works only from command line when logged in as root, need to send the command as root, but through a browser without giving others root access, of course.

shell_exec("ssh -i /root/.ssh/id_rsa /usr/local/psa/bin/ --create -mailbox true -cp_access true -mailbox true -passwd PASSWORDHERE \n");


exec("/usr/local/psa/bin/ --create -mailbox true -cp_access true -mailbox true -passwd PASSWORDHERE");

Here is the command that needs to execute whena  user registers. I left the username and password variables out for testing purposes.

/usr/local/psa/bin/ --create -mailbox true -cp_access true -mailbox true -passwd PASSWORDHERE


It eventually does TRY TO work, it seems that the page hangs and the email is not created. I think that it is a security thing keeping it from executing, but I am not sure. If anyone is a Plesk expert, I could really use assistance ont his one:)

Email: dude (A)

Question by:jeffparis
    LVL 15

    Accepted Solution

    So your ssh... command working from root. Great! That is step 1.

    Step 2: you're trying to run it not as root but as apache.
    So temporarily change the line in /etc/passwd


    so that you can test out apache access to the ssh...

    NOTE !!! only change the following for testing purposes so that you can su to apache from root and test it.

    # su - apache
    $ ssh...
    and make sure it works (you will need to setup all keys and other jazz).

    Step 3: Roll back /etc/passwd and try <?php exec('ssh...') ?> again. It shall work now.

    In any case it's a huge security risk and you are on your own etc. etc.

    BTW, first, you use -mailbox true twice and second, better add -qn to ssh (like ssh -qn -i...) to silence it and disable stdin reading.
    LVL 1

    Author Comment

    Dude, that rocks, i will test it later tonight and if it works, i will give you the points with an A!
    LVL 1

    Author Comment

    Ok, this rocks, however, it is asking for root's password. I will see if I can get around this. If you know how, I'd appreciate the advice.

    Thanks for the help!
    LVL 1

    Author Comment

    Soemthing like this would be easier, right?

    shell_exec('env -i htpasswd -n -b -m root ROOTPASSWORD \n /usr/local/psa/bin/ -c --mailbox true -passwd XXXXXX \n');

    LVL 15

    Expert Comment

    If you web server is on ns3 you don't need to ssh to it and you can go with sudo command.
    If not, you need to ssh to ns3 machine from web server machine and you need to setup public and private keys.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
    The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now