For the complete documentation index, see llms.txt. This page is also available as Markdown.

Go

Integrate Mailtrap with Go apps and projects for email sending using SDK, SMTP, or RESTful API

Mailtrap Go SDK on GitHub

Overview

Mailtrap can be integrated with Go apps and projects for email sending.

Email API/SMTP for Go

SDK integration

The Mailtrap Go SDK provides an idiomatic Go interface for the full Mailtrap feature set, with context.Context support and typed errors on every call. The SDK supports:

  • Transactional, bulk & batch email sending

  • Email template management

  • Sending domain management

  • Suppression list management

  • Webhook management

  • Email logs and sending stats

  • Sandbox email sending, projects, inboxes & message inspection

  • Contact management (contacts, lists, fields, imports & exports)

  • Account & organization management

Installation

Install the SDK:

Requires Go 1.23 or newer.

Minimal Example

Here's a minimal example to send your first email:

Get your API token from your Mailtrap account under Settings → API Tokens.

SMTP integration

To integrate SMTP with your Go app, navigate to the Integrations tab and copy-paste the credentials.

SMTP integration is compatible with any Go framework or library that sends emails via SMTP.

The standard library's net/smtp package is all you need — no third-party dependencies:

Read more in the SMTP integration guide.

RESTful API integration

To integrate Mailtrap using RESTful API, use the configuration available among Code samples under the API section.

API integration can be used with any Go framework or library that supports HTTP requests. For more details, refer to the API documentation.

Read more about API integration here.

Last updated

Was this helpful?