This method will send and save a new or an existing email to the system. If you include mail attachments then they must already exist in the server. You will need to provide the full path to the file. To see an example usage take a look at docs/REST/samples/email-service/send_email.php
POST https://gambio-shop.de/shop1/api.php/v2/emails/{email_id}
Parameter name | Value | Description | Additional |
---|---|---|---|
email_id | int64 | The email ID |
Required |
Read-only parameters such as a resource's ID field are to be omitted.
The request body takes a GXCustomerEmail resource, containing the following writable properties:
{
"attachments": [
{
"name": "nice_name_for_my_file.txt",
"path": "/var/www/html/shop/uploads/attachments/1434614398/myfile.txt"
}
],
"bcc": [
{
"contactName": "Chris Doe",
"emailAddress": "bcc@email.de"
}
],
"cc": [
{
"contactName": "Chloe Doe",
"emailAddress": "cc@email.de"
}
],
"contentHtml": "<strong>html content</strong>",
"contentPlain": "plain content",
"creationDate": "2015-06-04 14:36:00",
"isPending": false,
"recipient": {
"contactName": "Jane Doe",
"emailAddress": "recipient@email.de"
},
"replyTo": {
"contactName": "John Doe (Reply To)",
"emailAddress": "reply_to@email.de"
},
"sendDate": "2015-06-04 14:36:00",
"sender": {
"contactName": "John Doe",
"emailAddress": "sender@email.de"
},
"subject": "Test Subject"
}
{
"attachments": [
"string"
],
"bcc": [
"string"
],
"cc": [
"string"
],
"contentHtml": "string",
"creationDate": "string",
"isPending": "boolean",
"recipient": {
"contactName": "string",
"emailAddress": "string"
},
"sender": {
"contactName": "string",
"emailAddress": "string"
},
"sentDate": "string",
"subject": "string"
}
Name | Type | Description | Additional |
---|---|---|---|
attachments[] | array of string | Required | |
bcc[] | array of string | Required | |
cc[] | array of string | Required | |
contentHtml | string | Required | |
creationDate | string | Required | |
isPending | boolean | Required | |
recipient | object | GXCustomerEmailAddress | Required |
recipient.contactName | string | Required | |
recipient.emailAddress | string | Required | |
sender | object | GXCustomerEmailAddress | Required |
sender.contactName | string | Required | |
sender.emailAddress | string | Required | |
sentDate | string | Required | |
subject | string | Required |
In order to provide the authentication, you must insert the Basic Auth inside the HTTP header. The Basic Auth
is an encrypted base64 string that holds the following content: admin@example.org:12345
where the structure is
as follows: username:password
.
An example header would look as follows:
Authorization: Basic YWRtaW5Ac2hvcC5kZToxMjM0NQ==
This request requires the use of one of following authorisation methods:
BASIC
.
The following HTTP status codes may be returned, optionally with a response resource.
Status code | Description | Resource |
---|---|---|
201 | Created Upon success, returns the email send |
GXCustomerEmail |
400 | Bad Request (Email data missing) |
defaultErrorResponse |
404 | Not Found (Email record not found) |
defaultErrorResponse |
Here are some example implementations for this operation.
curl --request POST \ --header 'Authorization: Basic REPLACE_BASIC_AUTH' \ --header 'content-type: application/json' \ --data '{"id":0,"subject":"","sender":{"emailAddress":"","contactName":""},"recipient":{"emailAddress":"","contactName":""},"contentHtml":"","isPending":false,"creationDate":"","sentDate":"","bcc":[""],"cc":[""],"attachments":[""]}'
wget --quiet \ --method POST \ --header 'content-type: application/json' \ --header 'Authorization: Basic REPLACE_BASIC_AUTH' \ --body-data '{"id":0,"subject":"","sender":{"emailAddress":"","contactName":""},"recipient":{"emailAddress":"","contactName":""},"contentHtml":"","isPending":false,"creationDate":"","sentDate":"","bcc":[""],"cc":[""],"attachments":[""]}' \ --output-document
echo '{"id":0,"subject":"","sender":{"emailAddress":"","contactName":""},"recipient":{"emailAddress":"","contactName":""},"contentHtml":"","isPending":false,"creationDate":"","sentDate":"","bcc":[""],"cc":[""],"attachments":[""]}' | \ Authorization:'Basic REPLACE_BASIC_AUTH' \ content-type:application/json
HttpResponse response = Unirest.post("https://gambio-shop.de/shop1/api.php/v2/emails/{email_id}") .header("content-type", "application/json") .header("Authorization", "Basic REPLACE_BASIC_AUTH") .body("{\"id\":0,\"subject\":\"\",\"sender\":{\"emailAddress\":\"\",\"contactName\":\"\"},\"recipient\":{\"emailAddress\":\"\",\"contactName\":\"\"},\"contentHtml\":\"\",\"isPending\":false,\"creationDate\":\"\",\"sentDate\":\"\",\"bcc\":[\"\"],\"cc\":[\"\"],\"attachments\":[\"\"]}") .asString();
OkHttpClient client = new OkHttpClient(); MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"id\":0,\"subject\":\"\",\"sender\":{\"emailAddress\":\"\",\"contactName\":\"\"},\"recipient\":{\"emailAddress\":\"\",\"contactName\":\"\"},\"contentHtml\":\"\",\"isPending\":false,\"creationDate\":\"\",\"sentDate\":\"\",\"bcc\":[\"\"],\"cc\":[\"\"],\"attachments\":[\"\"]}"); Request request = new Request.Builder() .post(body) .addHeader("content-type", "application/json") .addHeader("Authorization", "Basic REPLACE_BASIC_AUTH") .build(); Response response = client.newCall(request).execute();
var request = new RestRequest(Method.POST); request.AddHeader("content-type", "application/json"); request.AddHeader("Authorization", "Basic REPLACE_BASIC_AUTH"); request.AddParameter("application/json", "{\"id\":0,\"subject\":\"\",\"sender\":{\"emailAddress\":\"\",\"contactName\":\"\"},\"recipient\":{\"emailAddress\":\"\",\"contactName\":\"\"},\"contentHtml\":\"\",\"isPending\":false,\"creationDate\":\"\",\"sentDate\":\"\",\"bcc\":[\"\"],\"cc\":[\"\"],\"attachments\":[\"\"]}", ParameterType.RequestBody); IRestResponse response = client.Execute(request);
const http = require("https"); const options = {
"method": "POST", "hostname": "gambio-shop.de", "port": null, "path": "/shop1/api.php/v2/emails/{email_id}", "headers": { "content-type": "application/json",
"Authorization": "Basic REPLACE_BASIC_AUTH" }
}; const req = http.request(options, function (res) {
const chunks = []; res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString()); });
}); req.write(JSON.stringify({
id: 0, subject: '', sender: {emailAddress: '', contactName: ''}, recipient: {emailAddress: '', contactName: ''}, contentHtml: '', isPending: false, creationDate: '', sentDate: '', bcc: [''], cc: [''], attachments: [''] })); req.end();
const request = require('request'); const options = {
method: 'POST', headers: {'content-type': 'application/json', Authorization: 'Basic REPLACE_BASIC_AUTH'}, body: { id: 0,
subject: '<ADD STRING VALUE>', sender: {emailAddress: '<ADD STRING VALUE>', contactName: '<ADD STRING VALUE>'}, recipient: {emailAddress: '<ADD STRING VALUE>', contactName: '<ADD STRING VALUE>'}, contentHtml: '<ADD STRING VALUE>', isPending: false, creationDate: '<ADD STRING VALUE>', sentDate: '<ADD STRING VALUE>', bcc: ['<ADD STRING VALUE>'], cc: ['<ADD STRING VALUE>'], attachments: ['<ADD STRING VALUE>'] },
json: true }; request(options, function (error, response, body) {
if (error) throw new Error(error); console.log(body);
});
const unirest = require("unirest"); const req = unirest("POST", "https://gambio-shop.de/shop1/api.php/v2/emails/{email_id}");
req.headers({
"content-type": "application/json", "Authorization": "Basic REPLACE_BASIC_AUTH" }); req.type("json");
req.send({ "id": 0, "subject": "", "sender": { "emailAddress": "<ADD STRING VALUE>",
"contactName": "<ADD STRING VALUE>" },
"recipient": { "emailAddress": "<ADD STRING VALUE>",
"contactName": "<ADD STRING VALUE>" },
"contentHtml": "", "isPending": false, "creationDate": "", "sentDate": "", "bcc": [ "<ADD STRING VALUE>"
],
"cc": [ "<ADD STRING VALUE>"
],
"attachments": [ "<ADD STRING VALUE>"
]
}); req.end(function (res) {
if (res.error) throw new Error(res.error); console.log(res.body);
});
const data = JSON.stringify({ "id": 0, "subject": "", "sender": { "emailAddress": "<ADD STRING VALUE>",
"contactName": "<ADD STRING VALUE>" },
"recipient": { "emailAddress": "<ADD STRING VALUE>",
"contactName": "<ADD STRING VALUE>" },
"contentHtml": "", "isPending": false, "creationDate": "", "sentDate": "", "bcc": [ "<ADD STRING VALUE>"
],
"cc": [ "<ADD STRING VALUE>"
],
"attachments": [ "<ADD STRING VALUE>"
]
}); const xhr = new XMLHttpRequest();
xhr.withCredentials = true; xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) { console.log(this.responseText);
}
}); xhr.open("POST", "https://gambio-shop.de/shop1/api.php/v2/emails/{email_id}");
xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("Authorization", "Basic REPLACE_BASIC_AUTH"); xhr.send(data);
const settings = { "async": true, "crossDomain": true, "method": "POST", "headers": { "content-type": "application/json",
"Authorization": "Basic REPLACE_BASIC_AUTH" },
"processData": false, "data": "{\"id\":0,\"subject\":\"\",\"sender\":{\"emailAddress\":\"\",\"contactName\":\"\"},\"recipient\":{\"emailAddress\":\"\",\"contactName\":\"\"},\"contentHtml\":\"\",\"isPending\":false,\"creationDate\":\"\",\"sentDate\":\"\",\"bcc\":[\"\"],\"cc\":[\"\"],\"attachments\":[\"\"]}" }; $.ajax(settings).done(function (response) {
console.log(response); });
<?php $curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://gambio-shop.de/shop1/api.php/v2/emails/{email_id}", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"id\":0,\"subject\":\"\",\"sender\":{\"emailAddress\":\"\",\"contactName\":\"\"},\"recipient\":{\"emailAddress\":\"\",\"contactName\":\"\"},\"contentHtml\":\"\",\"isPending\":false,\"creationDate\":\"\",\"sentDate\":\"\",\"bcc\":[\"\"],\"cc\":[\"\"],\"attachments\":[\"\"]}", CURLOPT_HTTPHEADER => [ "Authorization: Basic REPLACE_BASIC_AUTH",
"content-type: application/json" ],
]); $response = curl_exec($curl);
$err = curl_error($curl); curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err; } else { echo $response; }
<?php $request = new HttpRequest();
$request->setUrl('https://gambio-shop.de/shop1/api.php/v2/emails/{email_id}'); $request->setMethod(HTTP_METH_POST); $request->setHeaders([
'content-type' => 'application/json', 'Authorization' => 'Basic REPLACE_BASIC_AUTH' ]); $request->setBody('{"id":0,"subject":"","sender":{"emailAddress":"","contactName":""},"recipient":{"emailAddress":"","contactName":""},"contentHtml":"","isPending":false,"creationDate":"","sentDate":"","bcc":[""],"cc":[""],"attachments":[""]}');
try {
$response = $request->send(); echo $response->getBody();
} catch (HttpException $ex) { echo $ex; }
<?php $client = new http\Client;
$request = new http\Client\Request; $body = new http\Message\Body;
$body->append('{"id":0,"subject":"","sender":{"emailAddress":"","contactName":""},"recipient":{"emailAddress":"","contactName":""},"contentHtml":"","isPending":false,"creationDate":"","sentDate":"","bcc":[""],"cc":[""],"attachments":[""]}'); $request->setRequestUrl('https://gambio-shop.de/shop1/api.php/v2/emails/{email_id}');
$request->setRequestMethod('POST'); $request->setBody($body); $request->setHeaders([
'content-type' => 'application/json', 'Authorization' => 'Basic REPLACE_BASIC_AUTH' ]); $client->enqueue($request)->send();
$response = $client->getResponse(); echo $response->getBody();
import http.client conn = http.client.HTTPSConnection("gambio-shop.de")
payload = "{\"id\":0,\"subject\":\"\",\"sender\":{\"emailAddress\":\"\",\"contactName\":\"\"},\"recipient\":{\"emailAddress\":\"\",\"contactName\":\"\"},\"contentHtml\":\"\",\"isPending\":false,\"creationDate\":\"\",\"sentDate\":\"\",\"bcc\":[\"\"],\"cc\":[\"\"],\"attachments\":[\"\"]}"
headers = {
'content-type': "application/json",
'Authorization': "Basic REPLACE_BASIC_AUTH" } conn.request("POST", "/shop1/api.php/v2/emails/{email_id}", payload, headers)
res = conn.getresponse()
data = res.read() print(data.decode("utf-8"))
import requests payload = {
"id": 0,
"subject": "<ADD STRING VALUE>", "sender": { "emailAddress": "<ADD STRING VALUE>", "contactName": "<ADD STRING VALUE>" }, "recipient": { "emailAddress": "<ADD STRING VALUE>", "contactName": "<ADD STRING VALUE>" }, "contentHtml": "<ADD STRING VALUE>", "isPending": False, "creationDate": "<ADD STRING VALUE>", "sentDate": "<ADD STRING VALUE>", "bcc": ["<ADD STRING VALUE>"], "cc": ["<ADD STRING VALUE>"], "attachments": ["<ADD STRING VALUE>"] }
headers = { "content-type": "application/json",
"Authorization": "Basic REPLACE_BASIC_AUTH" }
response = requests.request("POST", url, json=payload, headers=headers)
print(response.text)
require 'uri' require 'net/http' require 'openssl' http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json' request["Authorization"] = 'Basic REPLACE_BASIC_AUTH' request.body = "{\"id\":0,\"subject\":\"\",\"sender\":{\"emailAddress\":\"\",\"contactName\":\"\"},\"recipient\":{\"emailAddress\":\"\",\"contactName\":\"\"},\"contentHtml\":\"\",\"isPending\":false,\"creationDate\":\"\",\"sentDate\":\"\",\"bcc\":[\"\"],\"cc\":[\"\"],\"attachments\":[\"\"]}" response = http.request(request)
puts response.read_body
CURL *hnd = curl_easy_init(); curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://gambio-shop.de/shop1/api.php/v2/emails/{email_id}"); struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json"); headers = curl_slist_append(headers, "Authorization: Basic REPLACE_BASIC_AUTH"); curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"id\":0,\"subject\":\"\",\"sender\":{\"emailAddress\":\"\",\"contactName\":\"\"},\"recipient\":{\"emailAddress\":\"\",\"contactName\":\"\"},\"contentHtml\":\"\",\"isPending\":false,\"creationDate\":\"\",\"sentDate\":\"\",\"bcc\":[\"\"],\"cc\":[\"\"],\"attachments\":[\"\"]}");
CURLcode ret = curl_easy_perform(hnd);
package main import (
"fmt"
"strings" "net/http" "io/ioutil" )
func main() {
url := "https://gambio-shop.de/shop1/api.php/v2/emails/{email_id}"
payload := strings.NewReader("{\"id\":0,\"subject\":\"<ADD STRING VALUE>\",\"sender\":{\"emailAddress\":\"<ADD STRING VALUE>\",\"contactName\":\"<ADD STRING VALUE>\"},\"recipient\":{\"emailAddress\":\"<ADD STRING VALUE>\",\"contactName\":\"<ADD STRING VALUE>\"},\"contentHtml\":\"<ADD STRING VALUE>\",\"isPending\":false,\"creationDate\":\"<ADD STRING VALUE>\",\"sentDate\":\"<ADD STRING VALUE>\",\"bcc\":[\"<ADD STRING VALUE>\"],\"cc\":[\"<ADD STRING VALUE>\"],\"attachments\":[\"<ADD STRING VALUE>\"]}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("content-type", "application/json") req.Header.Add("Authorization", "Basic REPLACE_BASIC_AUTH") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) }
#import NSDictionary *headers = @{ @"content-type": @"application/json",
@"Authorization": @"Basic REPLACE_BASIC_AUTH" };
NSDictionary *parameters = @{ @"id": @0,
@"subject": @"<ADD STRING VALUE>",
@"sender": @{ @"emailAddress": @"<ADD STRING VALUE>", @"contactName": @"<ADD STRING VALUE>" }, @"recipient": @{ @"emailAddress": @"<ADD STRING VALUE>", @"contactName": @"<ADD STRING VALUE>" }, @"contentHtml": @"<ADD STRING VALUE>", @"isPending": @NO, @"creationDate": @"<ADD STRING VALUE>", @"sentDate": @"<ADD STRING VALUE>", @"bcc": @[ @"<ADD STRING VALUE>" ], @"cc": @[ @"<ADD STRING VALUE>" ], @"attachments": @[ @"<ADD STRING VALUE>" ] }; NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://gambio-shop.de/shop1/api.php/v2/emails/{email_id}"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0]; [request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers]; [request setHTTPBody:postData]; NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) { NSLog(@"%@", error); } else { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; NSLog(@"%@", httpResponse); } }]; [dataTask resume];
import Foundation let headers = [
"content-type": "application/json", "Authorization": "Basic REPLACE_BASIC_AUTH" ] let parameters = [ "id": 0, "subject": "", "sender": [ "emailAddress": "<ADD STRING VALUE>",
"contactName": "<ADD STRING VALUE>" ],
"recipient": [ "emailAddress": "<ADD STRING VALUE>",
"contactName": "<ADD STRING VALUE>" ],
"contentHtml": "", "isPending": false, "creationDate": "", "sentDate": "", "bcc": [""], "cc": [""], "attachments": [""] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://gambio-shop.de/shop1/api.php/v2/emails/{email_id}")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0) request.httpMethod = "POST"
request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse) }
}) dataTask.resume()
open Cohttp_lwt_unix open Cohttp open Lwt let uri = Uri.of_string "https://gambio-shop.de/shop1/api.php/v2/emails/{email_id}" in
let headers = Header.add_list (Header.init ()) [ ("content-type", "application/json"); ("Authorization", "Basic REPLACE_BASIC_AUTH"); ] in let body = Cohttp_lwt_body.of_string "{\"id\":0,\"subject\":\"\",\"sender\":{\"emailAddress\":\"\",\"contactName\":\"\"},\"recipient\":{\"emailAddress\":\"\",\"contactName\":\"\"},\"contentHtml\":\"\",\"isPending\":false,\"creationDate\":\"\",\"sentDate\":\"\",\"bcc\":[\"\"],\"cc\":[\"\"],\"attachments\":[\"\"]}" in Client.call ~headers ~body `POST uri
= fun (res, body_stream) ->
(* Do stuff with the result *)