• Hi, Pleskians! We are running a UX testing of our upcoming product intended for server management and monitoring.
    We would like to invite you to have a call with us and have some fun checking our prototype. The agenda is pretty simple - we bring new design and some scenarios that you need to walk through and succeed. We will be watching and taking insights for further development of the design.
    If you would like to participate, please use this link to book a meeting. We will sent the link to the clickable prototype at the meeting.
  • (Plesk for Windows):
    MySQL Connector/ODBC 3.51, 5.1, and 5.3 are no longer shipped with Plesk because they have reached end of life. MariaDB Connector/ODBC 64-bit 3.2.4 is now used instead.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

E-Mail Register shell_exec PHP Script

MailServiceFree

New Pleskian
Dear PP community,

I want to create a free e-mail service.
I'm using a vServer with 200gb (for the first time) on Debian 6 with Parallels Plesk 11 backend.

Now I just want a simple php script which is for guests to register a new mail (for themselves).

I've asked a good programming friend if he could help me, so he did.

He has written a script like this:

Code:
<form method="post" action="">
<input type='hidden' name='submitted' id='submitted' value='1'/>


<label for='email' >Email Address:</label>
<input type='text' name='email' id='email' maxlength="50" />
<br> 
<label for='password' >Password*:</label>
<input type='password' name='password' id='password' maxlength="50" />
<input type="submit" name="submit" value="Submit" />


</form>


<?
function sanitize($data) {
$data = strip_tags(trim($data));
$search = array('/[^A-Za-z0-9\. -\!\?\(\)\<\>\@]/');
$data = preg_replace($search, '', $data);
return $data;
}




if(isset($_POST['email'])){
// STRIP OUT ANY UNWANTED STUFF
$_POST['email'] = sanitize($_POST['email']);
$_POST['password'] = sanitize($_POST['password']);




if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$email = $_POST['email'];
} else {
echo "Invalid email<br>";
$_POST['email'] = null;
return;
}


$password = $_POST['password'];




shell_exec ("/usr/local/psa/bin/./mail --create $email -passwd $password -mailbox true");
echo "Your account '$email' has been setup with password '$password'";
}


?>

Looks like it would work, I've tested it, but the shell_exec doesn't work correctly. (index.php permissions are at 755)
I have just this file as index.php I don't need more for the first time, I'll code the other stuff when the index.php works fine.

I've read a bit about Plesk and the creation of mails.
They have written, that shell_exec is disabled in Plesk by default and I have to activate it.

I don't know how and where I can do that.. do you know a solution?

PLEASE ANSWER IF YOU NOW THE SOLUTION...

And no, I won't use XML because I don't know how to work with it.

Thanks in advance!!
 
The shell_exec will not work because it is executed as the webserver user. Obviously that user has no permissions to alter Plesk settings and/or create mailaccounts. Otherwise _everyone_ on a shared server could adjust/change/modify server settings. CLI commands only work as root. You will either need to run sudo, so this is executed as root. But I would recommend using Plesk API/XML as it is much more secure.

shell_exec() is bad practice.
 
Back
Top