Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Mail Server
  • Search

Create email account with PHP

Questions regarding the Mail Server
Dovecot, Exim, RoundCube
Post Reply
  • Print view
Advanced search
1 post • Page 1 of 1
mateoagudelo
Posts: 4
Joined: Wed Jan 20, 2016 5:12 pm

Create email account with PHP
  • Quote

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

Hi, i want to create email accounts with php usign API of vestacp.

Code: Select all

<?php
// Server info
$vst_hostname   = 'domain.com';
$vst_username   = 'admin';
$vst_password   = 'password';
$vst_returncode = 'yes';
$vst_command    = 'v-add-mail-account';
// New account info
$username       = 'nicole';
$domain         = 'domain.com';
$acount         = 'nicol123'; //[email protected]
$password       = 'emailpassword';

// 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);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://' . $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);
$data = curl_exec($curl);
if($data == 0) {
    echo "User account has been successfuly";
} elseif($data == 4) {
	    echo "Duplicate account";
} else {
    echo "Error: " . $data;
I always get "User account has been successfuly" but the account is not created.
Top


Post Reply
  • Print view
1 post • Page 1 of 1

Return to “Mail Server”



  • 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