{"__v":2,"_id":"58b516864d67aa37003c745c","category":{"project":"54eb50e5615ffc1900305a16","version":"54eb63b859b1172100334fae","_id":"57a9cf4e944ea60e00dc3f74","__v":0,"sync":{"url":"","isSync":false},"reference":true,"createdAt":"2016-08-09T12:40:46.182Z","from_sync":false,"order":6,"slug":"email-messages","title":"Email messages"},"parentDoc":null,"project":"54eb50e5615ffc1900305a16","user":"58402330c0507319000634d5","version":{"__v":21,"_id":"54eb63b859b1172100334fae","forked_from":"54eb63a1867e1917009b711d","project":"54eb50e5615ffc1900305a16","createdAt":"2015-02-23T17:30:32.501Z","releaseDate":"2015-02-23T17:30:32.501Z","categories":["54eb63b959b1172100334faf","54eb63b959b1172100334fb0","54eb63b959b1172100334fb1","54eb63b959b1172100334fb2","54ed8dd4ab373e2300f50eae","54ed99b2ab373e2300f50ede","55153a6de68daa2f00cff838","551546edbc466623002afe72","5515472ac28d6125001b8884","55154749c28d6125001b8885","555d9b4106dfec0d00d38ea7","5613e06e433e5735007c7708","5624bbb785a31117001c5403","56669e857cc81e0d00253f8e","568b8d837a42220d00498311","56a632277ef6620d00e2f18a","56d8147c3eb4dd0b00201aac","57a9ce2fac6db30e000d7efd","57a9cf4e944ea60e00dc3f74","58172386715dce0f00da4aa0","582dc59ee1b8692300c0dd03","589b19b4fec2730f0082e040","58b04a023529383900a759b5","58b92d1598157a0f004869bf"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-02-28T06:19:50.681Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[{"language":"curl","code":"curl -s --user user:password \\\nhttps://api.infobip.com/email/1/send \\\n-F from='Jane Doe <jane.doe:::at:::somecompany.com>' \\\n-F to='john.smith@somedomain.com' \\\n-F subject='Mail subject text' \\\n-F text='Mail body text' \\\n-F bulkId='cusotmBulkId'"},{"language":"http","code":"POST /email/1/send HTTP/1.1\nHost: api.infobip.com\nAuthorization: Basic bWt1dGljMjpNdTtpMjAxMiws\nAccept: application/json\nContent-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW\n\n------WebKitFormBoundary7MA4YWxkTrZu0gW\nContent-Disposition: form-data; name=\"from\"\n\nJane Doe <jane.doe@somecompany.com>\n------WebKitFormBoundary7MA4YWxkTrZu0gW\nContent-Disposition: form-data; name=\"to\"\n\njohn.smith@somedomain.com\n------WebKitFormBoundary7MA4YWxkTrZu0gW\nContent-Disposition: form-data; name=\"subject\"\n\nMail subject text\n------WebKitFormBoundary7MA4YWxkTrZu0gW\nContent-Disposition: form-data; name=\"text\"\n\nMail body text\n------WebKitFormBoundary7MA4YWxkTrZu0gW\nContent-Disposition: form-data; name=\"bulkId\"\n\nA_CUSTOM_BULK_ID\n------WebKitFormBoundary7MA4YWxkTrZu0gW--\n\n"},{"code":"<?php\ndefine('MULTIPART_BOUNDARY','-----------------------'.md5(time()));\ndefine('EOL',\"\\r\\n\");// PHP_EOL cannot be used for emails we need the CRFL '\\r\\n'\n\n/*\n * Method to convert an associative array of parameters into the HTML body string\n*/\nfunction getBody($fields) {\n    $content = '';\n    foreach ($fields as $FORM_FIELD => $value) {\n        $content .= '--' . MULTIPART_BOUNDARY . EOL;\n        $content .= 'Content-Disposition: form-data; name=\"' . $FORM_FIELD . '\"' . EOL;\n        $content .= EOL . $value . EOL;\n    }\n    return $content . '--' . MULTIPART_BOUNDARY . '--'; // Email body should end with \"--\"\n}\n\n/*\n * Method to get the headers for a basic authentication with username and passowrd\n*/\nfunction getHeader($username, $password){\n    // basic Authentication\n    $auth = base64_encode(\"$username:$password\");\n\n    // Define the header\n    return array(\"Authorization:Basic $auth\", 'Content-Type: multipart/form-data ; boundary=' . MULTIPART_BOUNDARY );\n}\n\n// URL to the API that sends the email.\n$url = 'https://api.infobip.com/email/1/send';\n\n// Associate Array of the post parameters to be sent to the API\n$postData = array(\n    'from' => 'company@somecompany.com',\n    'to' => 'john.smith@somedomain.com',\n    'subject' => 'Mail subject text',\n    'text' => 'Mail body text',\n);\n\n// Create the stream context.\n$context = stream_context_create(array(\n    'http' => array(\n          'method' => 'POST',\n          'header' => getHeader('username', 'password'),\n          'content' =>  getBody($postData),\n    )\n));\n\n// Read the response using the Stream Context.\n$response = file_get_contents($url, false, $context);\nvar\n ?>\n","language":"php"}]},"method":"post","results":{"codes":[{"status":200,"language":"json","code":"{\n  \"bulkId\":\"cusotmBulkId\",\n  \"messages\": [\n    {\n      \"to\": \"john.smith@somedomain.com\",\n      \"messageCount\": 1,\n      \"messageId\": \"c268350e-c85e-41d1-b5a0-a60771b134bd\",\n      \"status\": {\n        \"groupId\": 1,\n        \"groupName\": \"PENDING\",\n        \"id\": 7,\n        \"name\": \"PENDING_ENROUTE\",\n        \"description\": \"Message sent to next instance\"\n      }\n    }\n  ]\n}","name":""}]},"settings":"554860d6d2c8410d006c215e","auth":"required","params":[{"_id":"57a1b44e5220910e002a16c0","ref":"","in":"body","required":false,"desc":"Email address with optional sender name. Example: \"Jane Doe <<jane.doe@somecompany.com>>\"","default":"","type":"string","name":"from"},{"_id":"57a1b44e5220910e002a16bf","ref":"","in":"body","required":false,"desc":"Email address of the recepient","default":"","type":"string","name":"to"},{"_id":"57a1b44e5220910e002a16be","ref":"","in":"body","required":false,"desc":"Message subject","default":"","type":"string","name":"subject"},{"_id":"57a1b44e5220910e002a16bd","ref":"","in":"body","required":false,"desc":"Body of the message","default":"","type":"string","name":"text"},{"_id":"58bcef3de6271d0f00dfcff2","ref":"","in":"body","required":false,"desc":"The ID uniquely identifies the sent Email request. This filter will enable you to query delivery reports for all the messages using just one request. You will receive a bulkId in the response after sending an Email request. If you don't set your own `bulkId`, unique ID will be generated by our system and returned in the API response.","default":"","type":"string","name":"bulkId"}],"url":"/email/:version/send"},"isReference":true,"order":1,"body":"# Response format\n\nOn success, response header HTTP status code will be `200 OK` and the message will be sent.\n\nIf you try to send message without authorization, you will receive an error `401 Unauthorized`.\n\n### Response\n\n|Parameter|Type|Description|\n|-|-|-|\n|*bulkId*|String|Either a user provided custom bulk id or an auto generated one in case bulkId was absent in the request.|\n|*messages*|MessageInfo[]|Array of sent message objects, one object per every message.|\n\n### MessageInfo\n\n|Parameter|Type|Description|\n|-|-|-|\n|*to*|String|The message destination address.|\n|*status*|[Status](#section-status)|Indicates whether the message is successfully sent, not sent, delivered, not delivered, waiting for delivery or any other possible status.|\n|*messageCount*|int|The number of sent message segments.|\n|*messageId*|String|The ID that uniquely identifies the message sent.|\n\n#### Status\n\n|Parameter|Type|Description|\n|-|-|-|\n|*groupId*|int|Status [group ID](http://dev.infobip.com/v1/docs/response-codes#status-object-example).|\n|*groupName*|String|Status [group name](http://dev.infobip.com/v1/docs/response-codes#status-object-example).|\n|*id*|int|Status [ID](http://dev.infobip.com/v1/docs/response-codes#status-object-example).|\n|*name*|String|Status [name](http://dev.infobip.com/v1/docs/response-codes#section-status-object-example).|\n|*description*|String|Human readable [description](http://dev.infobip.com/v1/docs/response-codes#status-object-example) of the status.|\n|*action*|String|[Action](http://dev.infobip.com/v1/docs/response-codes#status-object-example) that should be taken to eliminate the error.|\n\n------ \n### **Next:** [Fully featured email](doc:fully-featured-email)","excerpt":"This method allows you to send a single email message to one destination address.","slug":"simple-email","type":"endpoint","title":"Simple email"}

postSimple email

This method allows you to send a single email message to one destination address.

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Body Params

from:
string
Email address with optional sender name. Example: "Jane Doe <<jane.doe@somecompany.com>>"
to:
string
Email address of the recepient
subject:
string
Message subject
text:
string
Body of the message
bulkId:
string
The ID uniquely identifies the sent Email request. This filter will enable you to query delivery reports for all the messages using just one request. You will receive a bulkId in the response after sending an Email request. If you don't set your own `bulkId`, unique ID will be generated by our system and returned in the API response.

Examples


Result Format


Documentation

# Response format On success, response header HTTP status code will be `200 OK` and the message will be sent. If you try to send message without authorization, you will receive an error `401 Unauthorized`. ### Response |Parameter|Type|Description| |-|-|-| |*bulkId*|String|Either a user provided custom bulk id or an auto generated one in case bulkId was absent in the request.| |*messages*|MessageInfo[]|Array of sent message objects, one object per every message.| ### MessageInfo |Parameter|Type|Description| |-|-|-| |*to*|String|The message destination address.| |*status*|[Status](#section-status)|Indicates whether the message is successfully sent, not sent, delivered, not delivered, waiting for delivery or any other possible status.| |*messageCount*|int|The number of sent message segments.| |*messageId*|String|The ID that uniquely identifies the message sent.| #### Status |Parameter|Type|Description| |-|-|-| |*groupId*|int|Status [group ID](http://dev.infobip.com/v1/docs/response-codes#status-object-example).| |*groupName*|String|Status [group name](http://dev.infobip.com/v1/docs/response-codes#status-object-example).| |*id*|int|Status [ID](http://dev.infobip.com/v1/docs/response-codes#status-object-example).| |*name*|String|Status [name](http://dev.infobip.com/v1/docs/response-codes#section-status-object-example).| |*description*|String|Human readable [description](http://dev.infobip.com/v1/docs/response-codes#status-object-example) of the status.| |*action*|String|[Action](http://dev.infobip.com/v1/docs/response-codes#status-object-example) that should be taken to eliminate the error.| ------ ### **Next:** [Fully featured email](doc:fully-featured-email)