• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

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