/mail/add_account


POST https://api.sitehost.nz/1.3/mail/add_account.json

Create a new account on the specified server.

Form Parameters

ParameterTypeRequiredDescription
client_idintegerYesThe ID for the client that the server belongs to.Example: 1
server_namestringYesThe name of the server to create the account on.Example: my-mail-server
emailstringYesThe email address of the new account.Example: bruce@example.com
params[label]stringA label for the account.Example: Bruce
params[autoresponder]integerThe autoresponder status for the account. 0 is disabled, 1 is enabled.Example: 0
params[autoresponder_text]stringThe autoresponder text for the account.Example: I am out fighting crime.
params[spam_strategy]integerThe spam strategy for the account. 0 to disable, 1 to enable.Example: 0
params[password]stringYesThe password for the account.Example: imbatman
params[username]stringThe username for the account. Defaults to the email address if not set.Example: bruce@example.com
params[quota]integerThe quota for the account in MB. Defaults to 0 (unlimited) if not set.Example: 100

Code Samples

JavaScript PHP Rails Python
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("POST", "https://api.sitehost.nz/1.3/mail/add_account.json", false);

var data = new FormData();
data.append("apikey", "your_key_here");
data.append("client_id", "1");
data.append("server_name", "my-mail-server");
data.append("email", "bruce@example.com");
data.append("params[label]", "Bruce");
data.append("params[autoresponder]", "0");
data.append("params[autoresponder_text]", "I am out fighting crime.");
data.append("params[spam_strategy]", "0");
data.append("params[password]", "imbatman");
data.append("params[username]", "bruce@example.com");
data.append("params[quota]", "100");

xmlHttp.send(data);

var response = xmlHttp.responseText;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sitehost.nz/1.3/mail/add_account.json");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$body = array(
'apikey' => 'your_key_here',
'client_id' => 1,
'server_name' => 'my-mail-server',
'email' => 'bruce@example.com',
'params[label]' => 'Bruce',
'params[autoresponder]' => 0,
'params[autoresponder_text]' => 'I am out fighting crime.',
'params[spam_strategy]' => 0,
'params[password]' => 'imbatman',
'params[username]' => 'bruce@example.com',
'params[quota]' => 100,
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
require 'net/http'
require 'uri'

uri = URI.parse("https://api.sitehost.nz/1.3/mail/add_account.json")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri)

body = {"apikey" => "your_key_here",
"client_id" => 1,
"server_name" => "my-mail-server",
"email" => "bruce@example.com",
"params[label]" => "Bruce",
"params[autoresponder]" => 0,
"params[autoresponder_text]" => "I am out fighting crime.",
"params[spam_strategy]" => 0,
"params[password]" => "imbatman",
"params[username]" => "bruce@example.com",
"params[quota]" => 100,
}
request.set_form_data(body)

response = http.request(request)
import requests
from collections import OrderedDict

uri = 'https://api.sitehost.nz/1.3/mail/add_account.json'

# We need ordered dictionary because parameters have to be in the right order.
# Refer to Developer Notes for more information.
body = OrderedDict()

body['apikey'] = 'your_key_here'
body['client_id'] = 1
body['server_name'] = 'my-mail-server'
body['email'] = 'bruce@example.com'
body['params[label]'] = 'Bruce'
body['params[autoresponder]'] = 0
body['params[autoresponder_text]'] = 'I am out fighting crime.'
body['params[spam_strategy]'] = 0
body['params[password]'] = 'imbatman'
body['params[username]'] = 'bruce@example.com'
body['params[quota]'] = 100

response = requests.post(uri, data=body)

Response

200:

application/json
{
  "return": {
    "job_id": "3433562"
  },
  "msg": "Successful",
  "status": true
}