---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://sendcorex.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://sendcorex.com/llms.txt"
---

Source: https://sendcorex.com/nl/blog/send-email-go

Tutorial

# E-mail versturen met Go (net/smtp) via SMTP

De standaardbibliotheek is genoeg — geen externe afhankelijkheid nodig.

Door het Sendcorex-team·Bijgewerkt 21 sep 2026·7 min lezen

## Optie 1: net/smtp

De standaardbibliotheek van Go heeft alles wat je nodig hebt. Voor HTML-mail moet je zelf een MIME content-type-header in de berichttekst schrijven:

```
package main

import (
    "net/smtp"
    "os"
)

func main() {
    apiKey := os.Getenv("SENDCOREX_API_KEY")
    auth := smtp.PlainAuth("", apiKey, apiKey, "smtp.sendcorex.com")

    to := []string{"customer@example.com"}
    msg := []byte("To: customer@example.com\r\n" +
        "From: Your App <hello@yourdomain.com>\r\n" +
        "Subject: Welcome!\r\n" +
        "Content-Type: text/html; charset=UTF-8\r\n\r\n" +
        "<h1>You are in.</h1>")

    err := smtp.SendMail("smtp.sendcorex.com:587", auth, "hello@yourdomain.com", to, msg)
    if err != nil {
        panic(err)
    }
}
```

## Optie 2: REST API met net/http

```
body := []byte(`{"to":"customer@example.com","from":"hello@yourdomain.com","subject":"Welcome!","html":"<h1>You are in.</h1>"}`)

req, _ := http.NewRequest("POST", "https://graph.sendcorex.com/v3.0/emails", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")

resp, err := http.DefaultClient.Do(req)
```

## Veelvoorkomende fouten

| Symptoom | Oplossing |
| --- | --- |
| `535 Authentication failed` | Controleer of de API-key klopt en in beide velden van `PlainAuth` wordt gebruikt. |
| Bericht wordt als platte tekst getoond | De header `Content-Type: text/html` moet deel uitmaken van het ruwe bericht, vóór de lege regel. |

### Op deze pagina

Verstuur je eerste e-mail binnen minuten

Maak een gratis account, verifieer je domein en plak de code hierboven.

[Gratis beginnen — 3.000 e-mails/mnd](https://app.sendcorex.com/authentication/register?appid=smtp)

Geen creditcard nodig

## Lees verder

[Tutorial ### E-mail versturen met .NET (C#) via SMTP Gebruik System.Net.Mail of MailKit via SMTP — met HTML-e-mails, bijlagen, foutafhandeling en DNS-instelling. Gids lezen](https://sendcorex.com/nl/blog/send-email-dotnet) [Basis ### Wat is SMTP? Een uitleg in gewone taal SMTP is het protocol dat bijna elke e-mail op internet vervoert. Dit is wat het echt doet, stap voor stap — zonder RFC-jargon. Gids lezen](https://sendcorex.com/nl/blog/what-is-smtp) [Bezorgbaarheid ### SPF, DKIM en DMARC uitgelegd Drie DNS-records staan tussen je e-mails en de inbox. Dit is wat elk record echt bewijst, en wat er gebeurt als er één ontbreekt. Gids lezen](https://sendcorex.com/nl/blog/spf-dkim-dmarc-explained)

Verstuur je eerste e-mail binnen minuten

Maak een gratis account, verifieer je domein en plak de code hierboven.

Geen creditcard nodig

[Gratis beginnen — 3.000 e-mails/mnd](https://app.sendcorex.com/authentication/register?appid=smtp) [Prijzen bekijken](https://sendcorex.com/nl/pricing)
