Email Send

Send a outbound email.

URL

Request Method

  • POST

Request Header

  • content-type: application/json
  • X-API-Key: apiKey

Request Examples

curl --request POST \
     --url http://sgapi.yoni-tech.com/v1/email/send \
     --header 'content-type: application/json' \
     --header 'X-API-Key: Hs42eBZ6vuTR7oBSs3zq7HscgiAr6Y252Y5BbzrbKoI=' \
     --data '
{
  "from": "[email protected]",
  "to": "[email protected]",
  "subject": "Here a test email",
  "content": "Hi,This a test email from YoniTech!",
  "contentType": "text/html"
}
'
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"from\": \"[email protected]\",\"to\": \"[email protected]\",\"subject\": \"Here a test email\",\"content\": \"Hi,This a test email from YoniTech!\",\"contentType\": \"text/html\"}");
Request request = new Request.Builder()
  .url("http://sgapi.yoni-tech.com/v1/email/send")
  .post(body)
  .addHeader("content-type", "application/json")
  .addHeader("X-API-Key", "Hs42eBZ6vuTR7oBSs3zq7HscgiAr6Y252Y5BbzrbKoI=")
  .build();

Response response = client.newCall(request).execute();

Request Parameter

NameOptionalTypeDescription
fromyesStringsender email address, e.g.[email protected], After you configure DMARC, We will take current domain as the suffix of “from”.
toyesStringRecipient’s email addresses, separated by semicolons, e.g.[email protected];[email protected].
subjectyesStringsubject
contentyesStringemail content
contentTypeyesStringtext/html or text/plain
variablesnoStringvariable of content, in JSONArrary format, e.g.[{"age": "20", "name": "tom"},{"age": "21", "name": "jerry"}]
fromNamenoStringsender name, shown as: YoniService<[email protected]>
ccnoStringcc addresses, separated by semicolons
bccnoStringbcc addresses, separated by semicolons
replyTonoStringdefault reply addresses, separated by semicolons, cannot be more than 3. If “reply To” does not exist or is null, reply address defaults to “from”
summarynoStringcontent summary. When adding content summary, if content summary already exists, the former one will be replaced by the most current summary;if not, the content summary will be added to the email.

🚧

Note

  • assuming that “from” is YoniService<[email protected]>.If “fromName” is empty, “YoniService” will be set as “fromName”; if not, no processing is needed.
  • when sending emails, designate recipients with “to”. Multiple recipients are sent through multi-transmission (all recipients will be displayed). Designate cc recipients with parameter “cc”, and bcc recipients with “bcc”.
  • recipients of “to”, “cc” and “bcc” cannot be more than 100.
  • recipients of “summary” can only be used when contentType is text/html.
  • email content size should be no more than 200KB.
  • If it's a variable email, recipients of “cc” and “bcc” will not take effect ,at the same time, the number of objects in the variable array should be the same as the number of recipients “to”; recipients of “content”, “variables” please see the following case:
content:"<p>Hi, #name#</p><p> &nbsp; &nbsp;your order is #number#, please check it.</p><p>YoniTech</p>";
variables:[{
		"name": "tom",
		"number": "YN-20240212382763812723"
	},
	{
		"name": "jerry",
		"number": "YN-20240212382763812724"
	}]

Response Example

{
    "code": "0",
    "message": "success",
    "data": [
        {
            "emailIds": [
                "[email protected]",
                "[email protected]"
            ]
        }
    ]
}

Response Result

NameTypeDescription
codeStringYONI-TECH's respense code (error codes)
messageStringdescribe the result
dataObjectobj contain emailIds
data.emailIdsArrayunique identifier for every email