{"id":3425,"date":"2018-04-30T11:47:17","date_gmt":"2018-04-30T09:47:17","guid":{"rendered":"https:\/\/dev.serversmtp.com\/?page_id=3425"},"modified":"2018-04-30T11:47:17","modified_gmt":"2018-04-30T09:47:17","slug":"nl_service-smtp-api","status":"publish","type":"page","link":"https:\/\/serversmtp.com\/nl\/nl_service-smtp-api\/","title":{"rendered":"SMTP web API"},"content":{"rendered":"<p>Our <strong>SMTP\u00a0API<\/strong>\u00a0is a great way to tailor turboSMTP&#8217;s outgoing mail server as you prefer, intergrating it elswhere.<\/p>\n<p>At the moment we provide a<strong> Send <\/strong>method that allows you to create a script to run turboSMTP and <strong><a title=\"how to send transactional emails\" href=\"\/en\/transactional-email\">send transactional emails<\/a><\/strong>\u00a0(login confirmations, welcome messages, receipts etc.) <strong>via web<\/strong>.<\/p>\n<p>So if you have <strong>a website or an app<\/strong> and you need to send a message directly from there, you can implement this API in your script and manage it easily.<\/p>\n<p>Below you will find the full documentation. We are currently<strong> developing new API methods<\/strong>, so stay tuned for more!<span style=\"font-size: 1.3em; line-height: 1.3em;\">\u00a0<\/span><\/p>\n<h3>Download the sample source code<\/h3>\n<p><a class=\"cssbutton blue medium\" href=\"https:\/\/dashboard.serversmtp.com\/downloads\/turbo_send_email_code.zip\"><span>PHP<\/span><\/a> <a class=\"cssbutton blue medium\" href=\"https:\/\/dashboard.serversmtp.com\/downloads\/CSharp-turboSMTP-API.zip\"><span>C#<\/span><\/a> <a class=\"cssbutton blue medium\" href=\"https:\/\/dashboard.serversmtp.com\/downloads\/Java-turboSMTP-API.zip\"><span>Java<\/span><\/a> <a class=\"cssbutton blue medium\" href=\"https:\/\/dashboard.serversmtp.com\/downloads\/Python-turboSMTP-API.zip\"><span>Python<\/span><\/a> <a class=\"cssbutton blue medium\" href=\"https:\/\/dashboard.serversmtp.com\/downloads\/Perl-turboSMTP-API.zip\"><span>Perl<\/span><\/a> <a class=\"cssbutton blue medium\" href=\"https:\/\/dashboard.serversmtp.com\/downloads\/Ruby-turboSMTP-API.zip\"><span>Ruby<\/span><\/a><\/p>\n<hr \/>\n<p><span style=\"color: #005293; font-size: 1.5em; line-height: 1.3em;\">Send (Beta 1.0)<\/span><\/p>\n<p>The service allows you to send an email<\/p>\n<h3>Index<\/h3>\n<ul>\n<li class=\"index-item\" data-link=\"parameters\">Parameters<\/li>\n<li class=\"index-item\" data-link=\"post-request\">POST request<\/li>\n<li class=\"index-item\" data-link=\"mime-message\">MIME body message<\/li>\n<li class=\"index-item\" data-link=\"curl-request\">Example of email sending (curl)<\/li>\n<li class=\"index-item\" data-link=\"send-script-example\">Example of email sending (PHP)<\/li>\n<li class=\"index-item\" data-link=\"turbo-api-client\">TurboApiClient (PHP)<\/li>\n<li class=\"index-item\" data-link=\"download-source-code\">Download source code example (PHP)<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h3 id=\"parameters\">Parameters<a class=\"top-link\" href=\"#\"> [top]<\/a><\/h3>\n<table class=\"table table-striped table-bordered\">\n<thead>\n<tr>\n<th>Parameters<\/th>\n<th>Mandatory<\/th>\n<th>Bonds<\/th>\n<th>Descriptions<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>to<\/td>\n<td>Yes<\/td>\n<td>Valid email addresses.<\/td>\n<td>Recipients list. In case of multiple recipients, the addresses must be separated by a comma.<\/td>\n<\/tr>\n<tr>\n<td>subject<\/td>\n<td>No<\/td>\n<td>Max 700 characters string.<\/td>\n<td>The subject of the email to be sent.<\/td>\n<\/tr>\n<tr>\n<td>from<\/td>\n<td>Yes<\/td>\n<td>Valid email address.<\/td>\n<td>The sender address of the email to be sent.<\/td>\n<\/tr>\n<tr>\n<td>bcc<\/td>\n<td>No<\/td>\n<td>Valid email addresses.<\/td>\n<td>Blind carbon copy list. In case of multiple recipients, the addresses must be separated by a comma.<\/td>\n<\/tr>\n<tr>\n<td>cc<\/td>\n<td>No<\/td>\n<td>Valid email address<\/td>\n<td>Carbon copy list. In case of multiple recipients, the addresses must be separated by a comma.<\/td>\n<\/tr>\n<tr>\n<td>content<\/td>\n<td>No<\/td>\n<td><\/td>\n<td>Email&#8217;s textual content.<\/td>\n<\/tr>\n<tr>\n<td>html_content<\/td>\n<td>No<\/td>\n<td><\/td>\n<td>Email&#8217;s HTML content.<\/td>\n<\/tr>\n<tr>\n<td>custom_headers<\/td>\n<td>No<\/td>\n<td>Valid JSON format.<\/td>\n<td>Key collection value of custom headers to put in the email. Example:<\/p>\n<pre> {\"X-key1\":\"value1\", \"X-key2\":\"value2\"}<\/pre>\n<\/td>\n<\/tr>\n<tr>\n<td>mime_raw<\/td>\n<td>No<\/td>\n<td>MIME standard format.<\/td>\n<td>MIME type message, replacing content and html_content.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"post-request\"><\/h3>\n<h3>Post request<a class=\"top-link\" href=\"#\"> [top]<\/a><\/h3>\n<h4>Url<\/h4>\n<pre>https:\/\/api.turbo-smtp.com\/api\/mail\/send<\/pre>\n<p>The user authentication takes place through the following parameters:<\/p>\n<ul>\n<li><strong>authuser<\/strong>: Username<\/li>\n<li><strong>authpass<\/strong>: Password<\/li>\n<\/ul>\n<p>The authentication data can be handled as GET and POST parameters, or as the https request&#8217;s headers.<\/p>\n<h4>Example of Post request<\/h4>\n<pre>from:from_address@domain.com\r\nto:to1_address@domain.com,to2_address@domain.com\r\ncc:cc1_address@domain.com,cc2_address@domain.com\r\nbcc:bcc1_address@domain.com,bcc2_address@domain.com\r\nsubject:subject of email\r\ncontent:text content of email\r\nhtml_content: html content of email\r\ncustom_headers:{\"X-key1\":\"value1\", \"X-key2\":\"value2\"}\r\n<\/pre>\n<h4 id=\"post-response\">Post response<\/h4>\n<p>The server&#8217;s responses are in JSON format. The object&#8217;s members are:<\/p>\n<ul>\n<li><strong>message<\/strong>: outcome of the response &#8220;OK&#8221; in case of success, &#8220;error&#8221; in case of error<\/li>\n<li><strong>errors<\/strong>: (only in case of error) array containing the error messages<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h4 id=\"success-response\">Success response<\/h4>\n<pre> { \"message\":\"OK\" }<\/pre>\n<h4 id=\"error-response\">Error response<\/h4>\n<pre> { \"message\": \"error\",\"errors\": [\"error message\",...]}<\/pre>\n<h4>Example of an error response<\/h4>\n<pre> { \"message\": \"error\",\"errors\": [\"'broken@@@Address.@@' recipient email not valid\" , \"'broken2@@@Address2.@@222' bcc email not valid\"]}<\/pre>\n<p><strong>NOTE<\/strong>: this error is referred to a malformed email. We don&#8217;t do any hard\/soft bounce check at this stage, since the API only puts your email in our queues. If you want to know if a contact bounced you need to check it in the <a href=\"http:\/\/dashboard.serversmtp.com\/\">dashboard reports<\/a>.<\/p>\n<h3 id=\"mime-message\"><\/h3>\n<h3>MIME type body message<a class=\"top-link\" href=\"#\"> [top]<\/a><\/h3>\n<p>In case you want to send as the email&#8217;s body a MIME type message, you must send it as a POST parameter named &#8220;mime&#8221;.<\/p>\n<p>In this case the content and content_html parameters are ignored. The message must be standard. If you send a message without header you need in any case, as required by specification, to let an empty line before the body.<\/p>\n<p>This parameter allows to send a file inside the message.<\/p>\n<h3 id=\"curl-request\"><\/h3>\n<h3>Example of a (curl) email sending<a class=\"top-link\" href=\"#\"> [top]<\/a><\/h3>\n<p>Sample code to send an email using the curl command.<\/p>\n<h4>Email dispatch<\/h4>\n<p>Let&#8217;s send an email using the authentication key obtained from the previous call.<\/p>\n<pre>curl --Header \"authuser:_username\" --Header \"authpass:_password\" --data \"to=john.smith@domain.com&amp;subject=email subject string&amp;from=john.smith@domain.com&amp;bcc=mark.davies@domain.com&amp;cc=mary.davies@domain.com&amp;content=content email&amp;html_content=html content of email\" https:\/\/api.turbo-smtp.com\/api\/mail\/send<\/pre>\n<h3 id=\"send-script-example\"><\/h3>\n<h3>Example of (PHP) email sending<a class=\"top-link\" href=\"#\"> [top]<\/a><\/h3>\n<p>Sample PHP code to send an email using our API.<\/p>\n<h5>Source code<\/h5>\n<pre>require_once \"TurboApiClient.php\";\r\n\r\n\/\/ creation of the email to be sent\r\n$email = new Email();\r\n$email-&gt;setFrom(\"john.smith@domain.com\");\r\n$email-&gt;setToList(\"mark.davies@domain.com, bruce.campbell@domain.com\");\r\n$email-&gt;setCcList(\"mary.davies@domain.com, mary.smith@domain.com\");\r\n$email-&gt;setBccList(\"maria.campbell@domain.com, don.smith@domain.com\");\t\r\n$email-&gt;setSubject(\"subject\");\r\n$email-&gt;setContent(\"content\");\r\n$email-&gt;setHtmlContent(\"html content\");\r\n$email-&gt;addCustomHeader('X-FirstHeader', \"value\");\r\n$email-&gt;addCustomHeader('X-SecondHeader', \"value\");\r\n$email-&gt;addCustomHeader('X-Header-to-be-removed', 'value');\r\n$email-&gt;removeCustomHeader('X-Header-to-be-removed);\r\n\r\n\/\/ creation of a client that connects with turbo-smtp APIs\r\n$turboApiClient = new TurboApiClient(\"_username\", \"_password\");\r\n\r\n\/\/ email sending\r\n$response = $turboApiClient-&gt;sendEmail($email);\r\n\r\n\/\/ display of the operation's outcome\r\nvar_dump($response);\t\t\t\t\t\t\r\n<\/pre>\n<h3 id=\"turbo-api-client\"><\/h3>\n<h3>TurboApiClient (PHP)<a class=\"top-link\" href=\"#\"> [top]<\/a><\/h3>\n<p>A simple client useful to connect with our API.<\/p>\n<h5>source code<\/h5>\n<pre>require_once  \"TurboClient.php\";\r\nrequire_once  \"Email.php\";\r\n\r\nclass TurboApiClient{\r\n\t\r\n\tprotected $username;\r\n\tprotected $password;\r\n\tprivate $serverUrl = \"https:\/\/api.turbo-smtp.com\/api\";\r\n\r\n\tpublic function __construct($username, $password) {\r\n       $this-&gt;username = $username;\r\n\t   $this-&gt;password = $password;\r\n   }\r\n\r\n\tprotected function authorize(){\r\n\t\ttry {\r\n\t\t\t$api = new TurboClient($this-&gt;serverUrl, $this-&gt;username, $this-&gt;password);\r\n\t\t\treturn $api;\r\n\t\t} catch (Pest_Forbidden $ex) {\r\n\t\t    return null;\r\n\r\n\t\t}\r\n\t}\r\n\r\n\tpublic function sendEmail($email){\r\n\t\t$api = $this-&gt;authorize();\r\n\t\tif($api){\r\n\t\t\ttry {\r\n\t\t\t    \t$response = $api-&gt;post(\r\n\t\t\t    \t\t'\/mail\/send',\r\n\t\t\t       \t\t$email-&gt;getPostParameters()\r\n\t\t\t    \t);\r\n\t\t\t    return $response;\r\n\t\t\t} catch (Pest_NotFound $e) {\r\n\t\t\t    return $e;\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\treturn \"Authorization error\";\r\n\t\t}\r\n\t}\r\n};\r\n<\/pre>\n<h3 id=\"download-source-code\"><\/h3>\n<h3>Download the sample source code<a class=\"top-link\" href=\"#\"> [top]<\/a><\/h3>\n<p><a class=\"cssbutton blue medium\" href=\"https:\/\/dashboard.serversmtp.com\/downloads\/turbo_send_email_code.zip\"><span>PHP<\/span><\/a> <a class=\"cssbutton blue medium\" href=\"https:\/\/dashboard.serversmtp.com\/downloads\/CSharp-turboSMTP-API.zip\"><span>C#<\/span><\/a> <a class=\"cssbutton blue medium\" href=\"https:\/\/dashboard.serversmtp.com\/downloads\/Java-turboSMTP-API.zip\"><span>Java<\/span><\/a> <a class=\"cssbutton blue medium\" href=\"https:\/\/dashboard.serversmtp.com\/downloads\/Python-turboSMTP-API.zip\"><span>Python<\/span><\/a> <a class=\"cssbutton blue medium\" href=\"https:\/\/dashboard.serversmtp.com\/downloads\/Perl-turboSMTP-API.zip\"><span>Perl<\/span><\/a> <a class=\"cssbutton blue medium\" href=\"https:\/\/dashboard.serversmtp.com\/downloads\/Ruby-turboSMTP-API.zip\"><span>Ruby<\/span><\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Our SMTP\u00a0API\u00a0is a great way to tailor turboSMTP&#8217;s outgoing mail server as you prefer, intergrating it elswhere. At the moment we provide a Send method that allows you to create a script to run turboSMTP and send transactional emails\u00a0(login confirmations, welcome messages, receipts etc.) via web. So if you have a website or an app &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"SMTP web API\" class=\"read-more button\" href=\"https:\/\/serversmtp.com\/nl\/nl_service-smtp-api\/#more-3425\" aria-label=\"Lees meer over SMTP web API\">Discover more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_eb_attr":"","inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-3425","page","type-page","status-publish"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.3.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SMTP web API - smtp mail server - professional SMTP service provider<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/serversmtp.com\/nl\/nl_service-smtp-api\/\" \/>\n<meta name=\"twitter:label1\" content=\"Geschatte leestijd\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 minuten\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SMTP web API - smtp mail server - professional SMTP service provider","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/serversmtp.com\/nl\/nl_service-smtp-api\/","twitter_misc":{"Geschatte leestijd":"5 minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/serversmtp.com\/nl\/nl_service-smtp-api\/","url":"https:\/\/serversmtp.com\/nl\/nl_service-smtp-api\/","name":"SMTP web API - smtp mail server - professional SMTP service provider","isPartOf":{"@id":"https:\/\/serversmtp.com\/#website"},"datePublished":"2018-04-30T09:47:17+00:00","breadcrumb":{"@id":"https:\/\/serversmtp.com\/nl\/nl_service-smtp-api\/#breadcrumb"},"inLanguage":"nl-NL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/serversmtp.com\/nl\/nl_service-smtp-api\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/serversmtp.com\/nl\/nl_service-smtp-api\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/serversmtp.com\/nl\/"},{"@type":"ListItem","position":2,"name":"SMTP web API"}]},{"@type":"WebSite","@id":"https:\/\/serversmtp.com\/#website","url":"https:\/\/serversmtp.com\/","name":"smtp mail server - professional SMTP service provider","description":"smtp mail server - professional SMTP service provider","publisher":{"@id":"https:\/\/serversmtp.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/serversmtp.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"nl-NL"},{"@type":"Organization","@id":"https:\/\/serversmtp.com\/#organization","name":"Delivery Tech","url":"https:\/\/serversmtp.com\/","logo":{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/serversmtp.com\/#\/schema\/logo\/image\/","url":"https:\/\/serversmtp.com\/wp-content\/uploads\/2021\/11\/og-image-2.jpg","contentUrl":"https:\/\/serversmtp.com\/wp-content\/uploads\/2021\/11\/og-image-2.jpg","width":1200,"height":1128,"caption":"Delivery Tech"},"image":{"@id":"https:\/\/serversmtp.com\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/serversmtp.com\/nl\/wp-json\/wp\/v2\/pages\/3425"}],"collection":[{"href":"https:\/\/serversmtp.com\/nl\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/serversmtp.com\/nl\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/serversmtp.com\/nl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/serversmtp.com\/nl\/wp-json\/wp\/v2\/comments?post=3425"}],"version-history":[{"count":1,"href":"https:\/\/serversmtp.com\/nl\/wp-json\/wp\/v2\/pages\/3425\/revisions"}],"predecessor-version":[{"id":3426,"href":"https:\/\/serversmtp.com\/nl\/wp-json\/wp\/v2\/pages\/3425\/revisions\/3426"}],"wp:attachment":[{"href":"https:\/\/serversmtp.com\/nl\/wp-json\/wp\/v2\/media?parent=3425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}