API call example:
JSON
{ "function": "mailkit.sendmail_mass", "id": "client_id", "md5": "client_md5", "recipients": [ { "send_to": "email@email.eu", "mailinglist_id": 123456, "campaign_id": 123456, "subject":"Message subject", "message_data":"base64 encoded message body", "create_email":true, "customs": { "first_name": "First name", "last_name": "Last name", "custom1": "custom field", "custom2": "custom field" }, "content": { "var1": "variable content" }, "attachment": [ { "url": "URL of attachment nr. 1", "name": "name of attachment nr. 1", "data": "data of attachment nr. 1(base64)" }, { "url": "URL of attachment nr. 2", "name": "name of attachment nr. 2", "data": "data of attachment nr. 2(base64)" } ] }, { "send_to": "email2@email2.eu", "mailinglist_id": 123456, "campaign_id": 123456, "subject":"Message subject", "message_data":"base64 encoded message body", "create_email":true, "customs": { "first_name": "First name", "last_name": "Last name", "custom1": "custom field", "custom2": "custom field" }, "content": { "var1": "variable content" }, "attachment": [ { "url": "URL of attachment", "name": "name of attachment", "data": "data of attachment (base64)" } ] } ], "options" : { "id_send": "today" } }
XML
<?xml version="1.0"?>
<methodCall>
<methodName>mailkit.sendmail_mass</methodName>
<params>
<param>
<value>
<int>client_id</int>
</value>
</param>
<param>
<value>
<string>client_md5</string>
</value>
</param>
<param>
<value>
<array>
<data>
<value>
<struct>
<member>
<name>send_to</name>
<value>
<string>email@email.com</string>
</value>
</member>
<member>
<name>mailinglist_id</name>
<value>
<int>ID of mailing list</int>
</value>
</member>
<member>
<name>campaign_id</name>
<value>
<int>ID of campaign</int>
</value>
</member>
<member>
<name>subject</name>
<value>
<string>subject</string>
</value>
</member>
<member>
<name>message_data</name>
<value>
<string>content</string>
</value>
</member>
<member>
<name>create_email</name>
<value>
<string>TRUE</string>
</value>
</member>
<member>
<name>customs</name>
<value>
<struct>
<member>
<name>custom1</name>
<value>Custom field no.1</value>
</member>
<member>
<name>custom25</name>
<value>Custom field no.25</value>
</member>
<member>
<name>first_name</name>
<value>First name</value>
</member>
<member>
<name>last_name</name>
<value>Last name</value>
</member>
</struct>
</value>
</member>
<member>
<name>attachment</name>
<value>
<array>
<data>
<value>
<struct>
<member>
<name>url</name>
<value>
<string>url of attachment nr. 1</string>
</value>
</member>
<member>
<name>name</name>
<value>
<string>name of attachment nr. 1</string>
</value>
</member>
<member>
<name>data</name>
<value>data of attachment nr. 1 in Base64</value>
</member>
</struct>
</value>
<value>
<struct>
<member>
<name>url</name>
<value>
<string>url of attachment nr. 2</string>
</value>
</member>
<member>
<name>name</name>
<value>
<string>name of attachment nr. 2</string>
</value>
</member>
<member>
<name>data</name>
<value>data of attachment nr. 2 in Base64</value>
</member>
</struct>
</value>
</data>
</array>
</value>
</member>
<member>
<name>content</name>
<value>
<struct>
<member>
<name>var1</name>
<value>
<string>variable</string>
</value>
</member>
<member>
<name>other_name</name>
<value>
<string>other name</string>
</value>
</member>
</struct>
</value>
</member>
</struct>
</value>
</data>
</array>
</value>
</param>
<param>
<value>
<struct>
<member>
<name>id_send</name>
<value>
<string>today</string>
</value>
</member>
</struct>
</value>
</param>
</params>
</methodCall>
Values
client_id * = client ID can be found in your Mailkit account's menu Profile/Integration.
client_md5 * = MD5 code can be found in your Mailkit account's menu Profile/Integration.
send_to * = e-mail address of recipient
mailinglist_id * = ID of mailing list
campaign_id * = ID of campaign (only 1 campaign ID can be entered in 1 API call, i.e. the same campaign must be sent to all recipients)
subject = other subject of campaign (optional)
message_data (base64) = other content of message (optional)
create_email = add e-mail address to the mailing list:
- TRUE = recipient address will be added if not present in the mailing list yet
- FALSE = recipient address will not be added to the mailing list if not present and therefor no email will be sent
customs = recipient personalisation data (name, custom fields, etc.). Provided data will update the recipient's record in the mailing list (optional)
attachment = optional campaign attachment. There are two options how to add attachment(s) - referring to the url address where the attachment is located, or sending attachment data (base64 encoded). The attachment can only be attached to a transactional campaigns! If the attachment is used for a non-transactional message, the message will not be sent!
- url = attachment URL
- name = attachment filename
- data (base64) = attachment data
As mentioned above, you can send the attachment either by providing the URL where it is stored, eg on FTP, or you can base64 encode the attachment data and use it in the API call as the value for "data". However, you always need to use either "url" or "data". If you send values in both parameters ("url" and "data"), the value for "url" takes precedence and the value for "data" is ignored.
Attachment name (name):
- if you fill in "url", e.g. use the value - "https://path_to_file/attachment_2.pdf" - and do not fill in the value for "name", the attachment file in the e-mail will be named "attachment_2.pdf"
- if you fill in "url", e.g. use the value - "https://path_to_file/attachment_2.pdf" - and at the same time fill in the value for "name" - e.g. "Name sent via API", the attachment file in the email will be named "Name sent via API"
- if you fill in "data" (i.e. send base64 encoded attachment data) and at the same time fill in a value for "name" - eg "Name sent via API", the attachment file in the email will be named "Name sent via API"
- if you fill in "data" (ie send base64 encoded attachment data) and do not fill in a value for "name", the attachment file will be named "unnamed" in the email
content (base64) = variable content that gets stored in structures named shared (for key/value pairs), resp. data (for complex structures and arrays). Data from these structures can later be used in template using tags [% shared.VARIABLE_NAME -%], resp. [% data.STRUCTURE_NAME -%]. If an array of variables is passed in the content the individual values in the array are to be passed unenencoded.
id_send = using value "today" allows to merge subsequent deliveries into one single reporting delivery.
* required value
Successful call response:
JSON
{ "list": [ "email@email.eu", "email2@email2.eu" ], "data": "OK", "request_id": "123456", "error_status": 0 }
XML
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>data</name>
<value>
<string>OK</string>
</value>
</member>
<member>
<name>list</name>
<value>
<array>
<data>
<value>
<string>email@email.eu</string>
</value>
<value>
<string>email2@email2.eu</string>
</value>
</data>
</array>
</value>
</member>
</struct>
</value>
</param>
</params>
</methodResponse>
Values
data = OK = campaign will be sent
list = list of recipients
request_id = Identifier of the request that can be used to retrieve results and possible errors that occurred during processing of the request.
error_status
- 0 = succesfull request
- 1+ = unsuccesfull request