From ceb0877f1e4e5ca67c1fd56063d6a3afdd41eb88 Mon Sep 17 00:00:00 2001 From: Maciej Walusiak Date: Wed, 22 Jul 2026 12:09:23 +0200 Subject: [PATCH 1/2] MT-22695: Add Go SDK to the Go integration guide and Guides overview Decisions: - Guide restructured to match ruby-integration.md (SDK section, feature list, installation, minimal example, API-token hint); SMTP and RESTful API sections retained - net/smtp fallback sample added to the SMTP section since the SDK is API-only; credentials (live.smtp.mailtrap.io:587, user 'api') verified against falcon's Integrations tab source - Go card placed after Python, before the Laravel/Symfony framework cards; Go removed from the 'additional languages' sentence --- guides-and-tips/README.md | 4 +- guides-and-tips/sdk/go-integration.md | 112 ++++++++++++++++++++++++-- 2 files changed, 108 insertions(+), 8 deletions(-) diff --git a/guides-and-tips/README.md b/guides-and-tips/README.md index e8be8ba..293d108 100644 --- a/guides-and-tips/README.md +++ b/guides-and-tips/README.md @@ -13,9 +13,9 @@ Welcome to Mailtrap Guides & Tips! This section provides detailed, step-by-step Get started quickly with our official SDKs for your favorite programming language. -
:php: PHPOfficial PHP SDK for Mailtrapphp-integration.md
:node-js: Node.jsOfficial Node.js SDK for Mailtrapnodejs-integration.md
:gem: RubyOfficial Ruby SDK for Mailtrapruby-integration.md
:microsoft: .NETOfficial .NET SDK for Mailtrapdotnet-integration.md
:java: JavaOfficial Java SDK for Mailtrapjava-integration.md
:python: PythonOfficial Python SDK for Mailtrappython-integration.md
:laravel: LaravelLaravel integration with Mailtrap PHP SDKphp-integration.md
:symfony: SymfonySymfony integration with Mailtrap PHP SDKphp-integration.md
+
:php: PHPOfficial PHP SDK for Mailtrapphp-integration.md
:node-js: Node.jsOfficial Node.js SDK for Mailtrapnodejs-integration.md
:gem: RubyOfficial Ruby SDK for Mailtrapruby-integration.md
:microsoft: .NETOfficial .NET SDK for Mailtrapdotnet-integration.md
:java: JavaOfficial Java SDK for Mailtrapjava-integration.md
:python: PythonOfficial Python SDK for Mailtrappython-integration.md
:golang: GoOfficial Go SDK for Mailtrapgo-integration.md
:laravel: LaravelLaravel integration with Mailtrap PHP SDKphp-integration.md
:symfony: SymfonySymfony integration with Mailtrap PHP SDKphp-integration.md
-Browse all SDK integration guides in the navigation menu for additional languages including Go, Elixir, Scala, and Perl. +Browse all SDK integration guides in the navigation menu for additional languages including Elixir, Scala, and Perl. ## Third-Party Integrations diff --git a/guides-and-tips/sdk/go-integration.md b/guides-and-tips/sdk/go-integration.md index dec68d2..fa68216 100644 --- a/guides-and-tips/sdk/go-integration.md +++ b/guides-and-tips/sdk/go-integration.md @@ -1,18 +1,87 @@ --- description: >- - Learn how to integrate Mailtrap with Go applications using SMTP and RESTful - API for email sending. + Integrate Mailtrap with Go apps and projects for email sending using SDK, + SMTP, or RESTful API --- # Go -## Overview +Mailtrap Go SDK on GitHub + +### Overview Mailtrap can be integrated with Go apps and projects for email sending. -## Email API/SMTP for Go +### Email API/SMTP for Go + +#### SDK integration + +The [Mailtrap Go SDK](https://github.com/mailtrap/mailtrap-go) 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: + +{% code title="Terminal" %} +```bash +go get github.com/mailtrap/mailtrap-go +``` +{% endcode %} + +Requires Go 1.23 or newer. + +### Minimal Example + +Here's a minimal example to send your first email: + +{% code title="main.go" %} +```go +package main + +import ( + "context" + "fmt" + "log" -### SMTP integration + mailtrap "github.com/mailtrap/mailtrap-go" +) + +func main() { + client, err := mailtrap.NewClient("your-api-token") + if err != nil { + log.Fatal(err) + } + + resp, _, err := client.Send(context.Background(), &mailtrap.SendRequest{ + From: mailtrap.Address{Email: "hello@example.com", Name: "Mailtrap Test"}, + To: []mailtrap.Address{{Email: "recipient@example.com"}}, + Subject: "Hello from Mailtrap!", + Text: "Welcome to Mailtrap Email Sending!", + HTML: "

Welcome to Mailtrap Email Sending!

", + }) + if err != nil { + log.Fatal(err) + } + fmt.Println(resp.MessageIDs) +} +``` +{% endcode %} + +{% hint style="info" %} +Get your API token from your Mailtrap account under **Settings → API Tokens**. +{% endhint %} + +#### SMTP integration To integrate SMTP with your Go app, navigate to the **Integrations** tab and copy-paste the credentials. @@ -22,9 +91,40 @@ SMTP integration is compatible with any Go framework or library that sends email
+The standard library's `net/smtp` package is all you need — no third-party dependencies: + +{% code title="main.go" %} +```go +package main + +import ( + "log" + "net/smtp" +) + +func main() { + // Copy host, port, username, and password from the Integrations tab. + host := "live.smtp.mailtrap.io" + auth := smtp.PlainAuth("", "api", "your-api-token", host) + + msg := []byte("From: hello@example.com\r\n" + + "To: recipient@example.com\r\n" + + "Subject: Hello from Mailtrap!\r\n" + + "\r\n" + + "Welcome to Mailtrap Email Sending!\r\n") + + err := smtp.SendMail(host+":587", auth, "hello@example.com", + []string{"recipient@example.com"}, msg) + if err != nil { + log.Fatal(err) + } +} +``` +{% endcode %} + Read more about SMTP integration [here](https://app.gitbook.com/s/S3xyr7ba7aGO19rc8dSK/email-api-smtp/setup/smtp-integration). -### RESTful API integration +#### RESTful API integration To integrate Mailtrap using RESTful API, use the configuration available among **Code samples** under the API section. From ade1992ba69766e9f831dc68838d34bbe5414f1b Mon Sep 17 00:00:00 2001 From: Maciej Walusiak Date: Fri, 24 Jul 2026 13:11:42 +0200 Subject: [PATCH 2/2] MT-22695: Use descriptive link text for the SMTP integration link Decisions: - Only the link added by this PR is changed; the pre-existing 'here' link in the RESTful API section is left for a separate sweep --- guides-and-tips/sdk/go-integration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides-and-tips/sdk/go-integration.md b/guides-and-tips/sdk/go-integration.md index fa68216..1cbd2c7 100644 --- a/guides-and-tips/sdk/go-integration.md +++ b/guides-and-tips/sdk/go-integration.md @@ -122,7 +122,7 @@ func main() { ``` {% endcode %} -Read more about SMTP integration [here](https://app.gitbook.com/s/S3xyr7ba7aGO19rc8dSK/email-api-smtp/setup/smtp-integration). +Read more in the [SMTP integration guide](https://app.gitbook.com/s/S3xyr7ba7aGO19rc8dSK/email-api-smtp/setup/smtp-integration). #### RESTful API integration