---
title: "Invia Email | Tajo"
description: "Invia email transazionali tramite l'API Brevo"
url: https://tajo.io/it/docs/email-messaging/transactional-email/send-email/
markdown: https://tajo.io/it/docs/email-messaging/transactional-email/send-email.md
lang: it-IT
author: "Set Noa"
author_url: https://tajo.io/it/set-noa/
robots: noindex
---

Richiedi l’accesso anticipato

Inserisci il tuo nome e indirizzo email aziendale. Ti invieremo un link per confermare la richiesta di accesso a Tajo.

# Invia Email

[Set Noa](https://tajo.io/it/set-noa/)

Invia singole email transazionali utilizzando l’endpoint `/v3/smtp/email`.

## Endpoint

```http
POST /v3/smtp/email
```

## Corpo della Richiesta

### Email Base

```json
{
  "sender": {
    "name": "Your App",
    "email": "noreply@yourapp.com"
  },
  "to": [
    {
      "email": "user@example.com",
      "name": "John Doe"
    }
  ],
  "subject": "Welcome to our service!",
  "htmlContent": "<html><body><h1>Welcome!</h1><p>Thank you for signing up.</p></body></html>"
}
```

### Email Avanzata

```json
{
  "sender": {
    "name": "Your App",
    "email": "noreply@yourapp.com"
  },
  "to": [
    {
      "email": "user@example.com",
      "name": "John Doe"
    }
  ],
  "cc": [
    {
      "email": "cc@example.com",
      "name": "CC User"
    }
  ],
  "bcc": [
    {
      "email": "bcc@example.com"
    }
  ],
  "subject": "Order Confirmation #{{order_id}}",
  "htmlContent": "<html><body><h1>Order Confirmed</h1><p>Your order {{order_id}} has been confirmed.</p></body></html>",
  "textContent": "Your order {{order_id}} has been confirmed.",
  "params": {
    "order_id": "12345"
  },
  "tags": ["transactional", "order-confirmation"],
  "headers": {
    "X-Custom-Header": "custom-value"
  }
}
```

## Esempi di Codice

### JavaScript/Node.js

```javascript
const brevo = require('@getbrevo/brevo');

const apiInstance = new brevo.TransactionalEmailsApi();
apiInstance.setApiKey(brevo.TransactionalEmailsApiApiKeys.apiKey, process.env.BREVO_API_KEY);

const sendEmail = async () => {
  const sendSmtpEmail = new brevo.SendSmtpEmail();

  sendSmtpEmail.subject = "Welcome to our service!";
  sendSmtpEmail.htmlContent = "<html><body><h1>Welcome!</h1></body></html>";
  sendSmtpEmail.sender = { name: "Your App", email: "noreply@yourapp.com" };
  sendSmtpEmail.to = [{ email: "user@example.com", name: "John Doe" }];

  try {
    const result = await apiInstance.sendTransacEmail(sendSmtpEmail);
    console.log('Email sent:', result);
    return result;
  } catch (error) {
    console.error('Error sending email:', error);
    throw error;
  }
};
```

### Python

```python
import sib_api_v3_sdk
from sib_api_v3_sdk.rest import ApiException

configuration = sib_api_v3_sdk.Configuration()
configuration.api_key['api-key'] = 'YOUR_API_KEY'

api_instance = sib_api_v3_sdk.TransactionalEmailsApi(sib_api_v3_sdk.ApiClient(configuration))

send_smtp_email = sib_api_v3_sdk.SendSmtpEmail(
    to=[{"email": "user@example.com", "name": "John Doe"}],
    sender={"name": "Your App", "email": "noreply@yourapp.com"},
    subject="Welcome to our service!",
    html_content="<html><body><h1>Welcome!</h1></body></html>"
)

try:
    api_response = api_instance.send_transac_email(send_smtp_email)
    print(api_response)
except ApiException as e:
    print("Exception when calling TransactionalEmailsApi->send_transac_email: %s\n" % e)
```

### cURL

```bash
curl -X POST "https://api.brevo.com/v3/smtp/email" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "api-key: YOUR_API_KEY" \
  -d '{
    "sender": {
      "name": "Your App",
      "email": "noreply@yourapp.com"
    },
    "to": [
      {
        "email": "user@example.com",
        "name": "John Doe"
      }
    ],
    "subject": "Welcome to our service!",
    "htmlContent": "<html><body><h1>Welcome!</h1></body></html>"
  }'
```

## Risposta

### Risposta di Successo (201 Created)

```json
{
  "messageId": "<202301151234.12345@smtp-relay.mailin.fr>"
}
```

### Risposte di Errore

**Chiave API non valida (401)**

```json
{
  "code": "unauthorized",
  "message": "Invalid API key provided"
}
```

**Formato email non valido (400)**

```json
{
  "code": "invalid_parameter",
  "message": "Invalid email format in 'to' field"
}
```

**Limite di frequenza superato (429)**

```json
{
  "code": "too_many_requests",
  "message": "Rate limit exceeded"
}
```

## Parametri

### Parametri Obbligatori

| Parametro | Tipo | Descrizione |
| --- | --- | --- |
| `sender` | oggetto | Informazioni sul mittente |
| `to` | array | Array di oggetti destinatario |
| `subject` | stringa | Oggetto dell’email |

### Parametri Opzionali

| Parametro | Tipo | Descrizione |
| --- | --- | --- |
| `htmlContent` | stringa | Contenuto HTML dell’email |
| `textContent` | stringa | Contenuto testo dell’email |
| `cc` | array | Destinatari CC |
| `bcc` | array | Destinatari BCC |
| `replyTo` | oggetto | Indirizzo di risposta |
| `attachments` | array | Allegati di file |
| `params` | oggetto | Parametri template |
| `tags` | array | Tag email per il tracciamento |
| `headers` | oggetto | Intestazioni personalizzate |

## Variabili Template

Usa le variabili template nell’oggetto e nel contenuto:

```json
{
  "subject": "Welcome {{firstName}}!",
  "htmlContent": "<h1>Hello {{firstName}} {{lastName}}</h1>",
  "params": {
    "firstName": "John",
    "lastName": "Doe"
  }
}
```

## Allegati

Includi allegati di file:

```json
{
  "attachments": [
    {
      "content": "base64_encoded_content",
      "name": "invoice.pdf"
    },
    {
      "url": "https://example.com/document.pdf",
      "name": "document.pdf"
    }
  ]
}
```

## Best Practice

1. **Includi sempre contenuto HTML e testo** per una migliore recapitabilità
2. **Usa le variabili template** invece di concatenare il contenuto
3. **Includi le informazioni corrette del mittente** per evitare i filtri antispam
4. **Aggiungi tag** per il tracciamento e l’analisi
5. **Convalida gli indirizzi email** prima dell’invio
6. **Gestisci gli errori con eleganza** con logica di retry

## Limiti di Frequenza

- **Limite di frequenza dell’API**: nel livello generale, che ottengono tutti i piani, questo endpoint consente 1.000 richieste al secondo e 3.600.000 all’ora. Il livello avanzato (Professional ed Enterprise) ne consente 2.000 al secondo e il livello esteso (Enterprise) 6.000.
- **Volume di invio**: quante email puoi inviare dipende dal tuo piano Brevo, separatamente dal limite di frequenza.

Vedi [Limiti di frequenza](https://tajo.io/it/docs/rate-limits/) e la [pagina dei limiti di frequenza](https://developers.brevo.com/docs/api-limits) di Brevo.

## Tracciamento

Le email inviate tramite questo endpoint vengono automaticamente tracciate per:

- Stato di consegna
- Tassi di apertura
- Tracciamento dei clic
- Gestione dei rimbalzi

Visualizza le analisi dettagliate nel tuo dashboard Brevo sotto **Statistiche** → **Transazionale**.

## Endpoint Correlati

- Template Email
- Allegati
- [Statistiche Email](https://tajo.io/it/docs/analytics-reporting/)
