Call virtualmin API (create-user.pl) from PHP

Hello,
I would like to create a set of email users under a VirtualMin environment. I have programmed a PHP script that handles the registration, but I would need to create email users as well. I considered the Virtualmin API the easiest way, but I am having some problems.

I call from PHP
system(’/usr/sbin/virtualmin create-user --domain domain.com --user user --pass pass --quota 1048576 --real “John Smith”’);
but at first I was getting: /usr/sbin/virtualmin must be run as root

I have commented out the lines that check for user-root at the virtualmin script, but now I get:
Command create-user was not found

I would appreciate some help on this matter. Is it a permissions error still? Is there any easy way to this problem?

Thank you

When I try to run
/usr/share/webmin/virtual-server/create-user.pl

from another user (other than root), I get:

Error: Script was not run with full path (failed to find /usr/share/webmin/virtual-server/create-user.pl under )


Script was not run with full path (failed to find /usr/share/webmin/virtual-server/create-user.pl under )

I believe the php script must use Remote API documented here:
http://www.virtualmin.com/documentation/developer/http

Thank you Ronald! This solved my problem :slight_smile:

But I have a question:in the url"
https://yourserver:10000/virtual-server/remote.cgi?program=create-
alias&domain=foo.com&from=sales&to=joe@foo.com "what does the “sales” mean?

The “create-alias” option creates an email alias.

So in the above example, using “from=sales” makes the name of the alias “sales”.

And then, sending an email to “sales” will cause that email to go to the mailbox of “joe@foo.com”.

-Eric