Page 1 of 1

v-add-mail-account script "like gmail"

Posted: Thu Dec 26, 2019 7:21 am
by sirstrider2
Hey.
Trying to create script "Create email account via php" like gmail (free emails on website).
But something not working (emails not created). Can someone help with this?

index.php:
<html>
<head>
<meta charset="utf-8">
<title>blablabla</title>
</head>

<body>
<form action="testmail.php" method="post">
Username:<br>
<input type="text" name="username">
<br>
Email Address:<br>
<input type="email" name="email">
<br>
Password:<br>
<input type="password" name="password">
<br>
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
testmail.php
<?php

// Server credentials
$vst_hostname = 'mywebsite.com';
$vst_username = 'myusername';
$vst_password = 'mypassword';
$vst_returncode = 'yes';
$vst_command = 'v-add-mail-account';

// New Account
$username = $_POST['username'];
$domain = 'mywebsite.com';
$acount = $_POST['email'];
$password = $_POST['password'];

// Prepare POST query
$postvars = array(
'user' => $vst_username,
'password' => $vst_password,
'returncode' => $vst_returncode,
'cmd' => $vst_command,
'arg1' => $username,
'arg2' => $domain,
'arg3' => $acount,
'arg4' => $password
);
$postdata = http_build_query($postvars);

// Send POST query via cURL
$postdata = http_build_query($postvars);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://' . $vst_hostname . ':8083/api/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl);

// Check result
if($answer == 0) {
echo "User account has been successfuly created\n";
} else {
echo "Query returned error code: " .$answer. "\n";
}
?>

Re: v-add-mail-account script "like gmail"

Posted: Mon Jan 13, 2020 4:11 pm
by mateoagudelo
Could you solve the problem?