> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Code Examples: Send Email with turboSMTP in Any Language

> Copy-paste sending examples for the turboSMTP REST API covering cURL, Python, Node.js, PHP, Ruby, Go, Java, and C# with full authentication.

The turboSMTP REST API works with any language or tool that can make HTTP requests. Each example below sends a POST request to the global send endpoint with `consumerKey` and `consumerSecret` headers and a JSON body containing the standard message fields. Swap in your own credentials and addresses, then run the code to send your first email.

> [!TIP]
>
> Replace `YOUR_CONSUMER_KEY` and `YOUR_CONSUMER_SECRET` with the keys from your dashboard at **Settings → Integrations → API Keys**. Your Consumer Secret is shown only once at creation time, so store it securely.

```bash cURL theme={"system"}
curl -X POST 'https://api.turbo-smtp.com/api/v2/mail/send' \
  -H 'consumerKey: YOUR_CONSUMER_KEY' \
  -H 'consumerSecret: YOUR_CONSUMER_SECRET' \
  -H 'Content-Type: application/json' \
  -d '{
    "from": "hello@your-company.com",
    "to": "recipient@example.com",
    "subject": "Hello from turboSMTP",
    "content": "This is a plain text message.",
    "html_content": "<p>This is an <strong>HTML</strong> message.</p>"
  }'
```

```python Python theme={"system"}
import requests

url = 'https://api.turbo-smtp.com/api/v2/mail/send'
headers = {
    'consumerKey': 'YOUR_CONSUMER_KEY',
    'consumerSecret': 'YOUR_CONSUMER_SECRET',
    'Content-Type': 'application/json'
}
payload = {
    'from': 'hello@your-company.com',
    'to': 'recipient@example.com',
    'subject': 'Hello from turboSMTP',
    'content': 'This is a plain text message.',
    'html_content': '<p>This is an <strong>HTML</strong> message.</p>'
}
response = requests.post(url, headers=headers, json=payload, timeout=30)
print(response.status_code, response.json())
```

```javascript Node.js theme={"system"}
const axios = require('axios');

axios.post('https://api.turbo-smtp.com/api/v2/mail/send', {
  from: 'hello@your-company.com',
  to: 'recipient@example.com',
  subject: 'Hello from turboSMTP',
  content: 'This is a plain text message.',
  html_content: '<p>This is an <strong>HTML</strong> message.</p>'
}, {
  headers: {
    consumerKey: 'YOUR_CONSUMER_KEY',
    consumerSecret: 'YOUR_CONSUMER_SECRET',
    'Content-Type': 'application/json'
  }
}).then(res => console.log(res.data));
```

```php PHP theme={"system"}
<?php
$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => 'https://api.turbo-smtp.com/api/v2/mail/send',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => [
    'consumerKey: YOUR_CONSUMER_KEY',
    'consumerSecret: YOUR_CONSUMER_SECRET',
    'Content-Type: application/json'
  ],
  CURLOPT_POSTFIELDS => json_encode([
    'from' => 'hello@your-company.com',
    'to'   => 'recipient@example.com',
    'subject' => 'Hello from turboSMTP',
    'content' => 'This is a plain text message.',
    'html_content' => '<p>This is an <strong>HTML</strong> message.</p>'
  ])
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

```ruby Ruby theme={"system"}
require 'net/http'
require 'json'

uri = URI('https://api.turbo-smtp.com/api/v2/mail/send')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri.path)
request['consumerKey'] = 'YOUR_CONSUMER_KEY'
request['consumerSecret'] = 'YOUR_CONSUMER_SECRET'
request['Content-Type'] = 'application/json'
request.body = {
  from: 'hello@your-company.com',
  to: 'recipient@example.com',
  subject: 'Hello from turboSMTP',
  content: 'This is a plain text message.',
  html_content: '<p>This is an <strong>HTML</strong> message.</p>'
}.to_json

response = http.request(request)
puts response.body
```

```go Go theme={"system"}
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
    "log"
    "time"
)

func main() {
    payload := map[string]string{
        "from":         "hello@your-company.com",
        "to":           "recipient@example.com",
        "subject":      "Hello from turboSMTP",
        "content":      "This is a plain text message.",
        "html_content": "<p>This is an <strong>HTML</strong> message.</p>",
    }
    body, err := json.Marshal(payload)
    if err != nil {
        log.Fatal(err)
    }
    req, err := http.NewRequest("POST", "https://api.turbo-smtp.com/api/v2/mail/send", bytes.NewBuffer(body))
    if err != nil {
        log.Fatal(err)
    }
    req.Header.Set("consumerKey", "YOUR_CONSUMER_KEY")
    req.Header.Set("consumerSecret", "YOUR_CONSUMER_SECRET")
    req.Header.Set("Content-Type", "application/json")
    client := &http.Client{Timeout: 30 * time.Second}
    resp, err := client.Do(req)
    if err != nil {
        log.Fatal(err)
    }
    defer resp.Body.Close()
    fmt.Println(resp.Status)
}
```

```java Java theme={"system"}
import java.net.http.*;
import java.net.URI;
import java.nio.charset.StandardCharsets;

public class SendEmail {
    public static void main(String[] args) throws Exception {
        String json = "{\"from\":\"hello@your-company.com\"," +
            "\"to\":\"recipient@example.com\"," +
            "\"subject\":\"Hello from turboSMTP\"," +
            "\"content\":\"This is a plain text message.\"," +
            "\"html_content\":\"<p>This is an <strong>HTML</strong> message.</p>\"}";

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.turbo-smtp.com/api/v2/mail/send"))
            .header("consumerKey", "YOUR_CONSUMER_KEY")
            .header("consumerSecret", "YOUR_CONSUMER_SECRET")
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(json, StandardCharsets.UTF_8))
            .build();
        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
```

```csharp C# theme={"system"}
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;

using var client = new HttpClient();
client.DefaultRequestHeaders.Add("consumerKey", "YOUR_CONSUMER_KEY");
client.DefaultRequestHeaders.Add("consumerSecret", "YOUR_CONSUMER_SECRET");

var payload = new {
    from = "hello@your-company.com",
    to = "recipient@example.com",
    subject = "Hello from turboSMTP",
    content = "This is a plain text message.",
    html_content = "<p>This is an <strong>HTML</strong> message.</p>"
};

var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.turbo-smtp.com/api/v2/mail/send", content);
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

## Before you run the examples

Use credentials with **HTTP API Sending** enabled and a sender domain configured for your account. Python uses the `requests` package (`python -m pip install requests`); the Node.js example uses `axios` (`npm install axios`). PHP requires its cURL extension, and the Java example requires Java 11 or later. The C# example uses top-level statements in a modern .NET console project.

To send through turboSMTP's European infrastructure, replace `api.turbo-smtp.com` with `api.eu.turbo-smtp.com`. turboSMTP is an Italian company with European servers; see [hosts and data residency](/docs/api-reference/base-urls.md).

## SDKs

turboSMTP publishes official source repositories with API clients and examples. See [Official SDKs](/docs/integrations/sdks.md) for their status and requirements.

> [card] [C# SDK](https://github.com/turboSMTP/turboSMTP-csharp)
>
> C# source and examples. The SDK project currently targets .NET Framework 4.8.

> [card] [PHP SDK](https://github.com/turboSMTP/turboSMTP-php)
>
> PHP source and examples. Check runtime requirements in the repository.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.