Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Dev Section Scripting / API
  • Search

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

Questions regarding the API
Application Programming Interface
Post Reply
  • Print view
Advanced search
2 posts • Page 1 of 1
sirstrider2
Posts: 1
Joined: Thu Dec 26, 2019 7:15 am

Os: CentOS 6x
Web: apache + nginx
v-add-mail-account script "like gmail"
  • Quote

Post by sirstrider2 » Thu Dec 26, 2019 7:21 am

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";
}
?>
Top

mateoagudelo
Posts: 4
Joined: Wed Jan 20, 2016 5:12 pm

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

Post by mateoagudelo » Mon Jan 13, 2020 4:11 pm

Could you solve the problem?
Top


Post Reply
  • Print view

2 posts • Page 1 of 1

Return to “Scripting / API”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password