Golang Receive Email: How to Receive and Read Email in Go
Golang receive email guide: create an address in code, wait for the next message, read the inbox, save attachments and get new mail on a webhook.

To receive email in Golang, a program needs two things: an address that takes mail, and a way to read what lands there. The standard library sends with net/smtp and has no client for reading, so the usual answers are a third-party IMAP package with a mailbox password, or an SMTP server of your own plus a MIME parser. An email API is shorter: create the address in code, and read each message as a Go struct with the text, HTML and attachments already parsed.
Typical jobs: save the PDF from a supplier’s invoice, pick a sign-in code out of a verification email in a test, or hand a customer’s reply to your service.
This tutorial shows how to receive and read email in Go with Mailcycle’s Go SDK, the mailcycle.email/go module. You’ll create an address, list and open messages, save attachments to disk, wait for the next email, and then get new mail pushed to a net/http handler by webhook.
It is the receiving half of How to send email from Go (Golang), which covers sending, HTML email from html/template files, a reusable mailer package and threaded replies. This one goes deep on the inbox. Every snippet here builds and passes go vet against v0.11.0 of the SDK.
Quick answer: how to receive email in Go
Get the module, sign in with your recovery phrase, create an address, and call WaitFor. It returns when a message arrives, parsed and decrypted, with the sender, subject, text, HTML and attachments as plain struct fields.
go get mailcycle.email/go
export MAILCYCLE_PHRASE="twelve words ..." # from sign-up, see Prerequisites
package main
import (
"fmt"
"log"
"os"
"time"
"mailcycle.email/go" // package mailcycle
)
func main() {
mc, err := mailcycle.SignIn(os.Getenv("MAILCYCLE_PHRASE"), mailcycle.Options{})
if err != nil {
log.Fatal(err) // an unset MAILCYCLE_PHRASE is named here
}
address, err := mc.Addresses().Create(mailcycle.NewAddress{
Prefix: "inbound",
Label: "Go inbox",
})
if err != nil {
log.Fatal(err)
}
fmt.Println("Send an email to", address.EmailAddress)
message, err := mc.Messages().WaitFor(mailcycle.WaitOptions{
AddressID: address.ID,
Timeout: 5 * time.Minute, // the default is one minute
})
if mailcycle.ErrorCode(err) == "timeout" {
log.Fatal("nothing arrived in five minutes")
}
if err != nil {
log.Fatal(err)
}
fmt.Println(message.FromAddress, message.Subject)
fmt.Println(message.Text)
}
Run it, send an email to the address it prints from any mail app, and the program prints what you sent. The rest of this guide is what a real service needs around that: paging, attachments, push and errors.
Prerequisites
- Go 1.26 or later. Check with
go version. The module path ismailcycle.email/goand the package name ismailcycle. - A Mailcycle account. Receiving works on every plan when your program signs in with the recovery phrase. API keys and webhooks start at Operator. Pricing has the plans.
- Your recovery phrase, in an environment variable named
MAILCYCLE_PHRASE, for any process that opens mail. It comes from sign-up: make a free account at app.mailcycle.email/operator/signup and keep the twelve words it shows, or create one from Go withmailcycle.CreateAccount("", mailcycle.Options{}), which returns the client and the new phrase. Write it to a file with0o600permissions andexport MAILCYCLE_PHRASE="$(cat mailcycle-phrase.txt)". The Go SDK guide shows both.
Step 1: Get the Go module
go get mailcycle.email/go
The package is flat, with plain structs and errors you can switch on. Its methods hang off handles such as mc.Addresses(), mc.Messages(), mc.Webhooks() and mc.Events().
Step 2: Sign in and create an address
mailcycle.SignIn(phrase, mailcycle.Options{}) works on every plan. Each sign-in opens a 30-day session, so a program that runs often can keep mc.SessionToken() and pick it up again with mailcycle.Resume(token, phrase, mailcycle.Options{}).
An address that receives mail needs a public key the mail server can encrypt to. Addresses().Create() derives that key from your phrase and uploads only the public half.
address, err := mc.Addresses().Create(mailcycle.NewAddress{
Prefix: "invoices",
Label: "Supplier invoices",
RetentionDays: 30,
})
if err != nil {
log.Fatal(err)
}
fmt.Println(address.EmailAddress, address.ID)
addresses, err := mc.Addresses().List()
if err != nil {
log.Fatal(err)
}
for _, existing := range addresses {
fmt.Println(existing.EmailAddress, existing.Label, existing.Receives)
}
The fields on NewAddress:
Prefix: "invoices"givesinvoices-plus a random ending on a shared domain.Style(mailcycle.StylePerson,StyleBusiness,StyleTeamorStyleNeutral) rolls a name in that style.LocalPartasks for an exact name. Any name you type needs Scale or above, and so doesDomainwith your own domain.Labelis encrypted on your machine, so the server stores it as ciphertext.RetentionDaysis 1 to 90, and 7 when left at zero.
Save address.ID, the ibx_... id: every reading call takes it.
Step 3: List and read emails in the inbox
Messages().List returns one page of a folder, newest first:
page, err := mc.Messages().List(address.ID, mailcycle.ListOptions{Limit: 20})
if err != nil {
log.Fatal(err)
}
for _, message := range page.Messages {
flag := " "
if !message.Read {
flag = "*"
}
fmt.Println(flag, message.ReceivedAt, message.FromAddress, message.Subject)
}
if page.NextCursor != "" {
older, err := mc.Messages().List(address.ID, mailcycle.ListOptions{Limit: 20, Cursor: page.NextCursor})
if err != nil {
log.Fatal(err)
}
fmt.Println(len(older.Messages), "older messages on the next page")
}
Limit goes up to 200. NextCursor is opaque: pass it back as Cursor as it came, and it is empty on the last page. To walk a whole folder, All pages for you:
all, err := mc.Messages().All(address.ID, "inbox")
if err != nil {
log.Fatal(err)
}
var invoices []mailcycle.Message
for _, message := range all {
if strings.Contains(strings.ToLower(message.Subject), "invoice") && len(message.Attachments) > 0 {
invoices = append(invoices, message)
}
}
fmt.Println(len(invoices), "invoices with files attached")
Message content is encrypted, so you decrypt and then filter in Go, as above. Pass "sent", "junk", "trash" or "starred" as the folder to read another one.
What is in a Message
Each Message is a plain struct, already parsed from MIME and decrypted:
| Field | What it holds |
|---|---|
ID, AddressID |
The message’s msg_... id and the address it arrived at. |
ReceivedAt |
When it arrived, as an RFC 3339 string in UTC. |
FromAddress, FromName |
The sender’s address and display name. |
ReplyTo |
Where a reply should go: the Reply-To header if set, otherwise From. |
To, Subject |
The recipient and the subject line. |
Text |
The plain-text body. |
HTML |
The HTML body exactly as sent. Do not render this one. |
SafeHTML |
The HTML with remote images, trackers and embeds removed. |
Attachments |
A slice of Attachment: Index, Filename, MimeType, Size, ContentID, Stored. |
MessageID |
The sender’s Message-ID header, used to thread a reply. |
Read, Starred, Folder |
The message’s state. |
Opened |
false if it could not be decrypted: no phrase, or the wrong one. |
A message that does not open comes back with Opened set to false and empty content rather than an error, so one bad message never hides the rest of a page.
Read the email body in Go: Text, HTML and SafeHTML
Most mail carries a plain-text and an HTML part. Use Text for anything you parse, such as codes, order numbers or a reply to hand to a model. If you show the HTML anywhere, use SafeHTML:
message, err := mc.Messages().Get("msg_91be02c4a7d1")
if err != nil {
log.Fatal(err)
}
if !message.Opened {
log.Fatal("this message did not open: check the recovery phrase")
}
if message.Text == "" {
fmt.Println("(no plain-text part)")
} else {
fmt.Println(message.Text)
}
if message.SafeHTML != "" {
if err := os.WriteFile("preview.html", []byte(message.SafeHTML), 0o600); err != nil {
log.Fatal(err)
}
fmt.Println(len(message.Blocked), "remote items taken out")
}
Get fetches one message by id, from any folder. SafeHTML is the HTML the Mailcycle apps show: remote images, tracking pixels and embeds are taken out, so opening it does not tell the sender when you read it. If you embed it in a page of your own, put it in a sandboxed <iframe>.
Download email attachments in Go
Attachments are listed on the message and fetched one at a time. Their bodies are encrypted like the message, and Attachment opens them on your machine. This function saves a message’s files safely:
func saveAttachments(mc *mailcycle.Client, message mailcycle.Message, folder string) ([]string, error) {
target := filepath.Join(folder, message.ID)
var saved []string
for _, attachment := range message.Attachments {
if !attachment.Stored {
continue // an empty part: nothing to fetch
}
if attachment.ContentID != "" {
continue // an image the HTML shows inline, like a logo
}
data, err := mc.Messages().Attachment(message, attachment.Index) // opened on this machine
if err != nil {
return saved, err
}
if err := os.MkdirAll(target, 0o700); err != nil {
return saved, err
}
name := filepath.Base(strings.ReplaceAll(attachment.Filename, "\\", "/"))
if name == "." || name == "/" || name == "" {
name = "attachment"
}
path := filepath.Join(target, fmt.Sprintf("%d-%s", attachment.Index, name))
if err := os.WriteFile(path, data, 0o600); err != nil {
return saved, err
}
saved = append(saved, path)
}
return saved, nil
}
Then process every unread message that has files, and mark each one read so the next run skips it:
all, err := mc.Messages().All(address.ID, "inbox")
if err != nil {
log.Fatal(err)
}
for _, message := range all {
if message.Read || len(message.Attachments) == 0 {
continue
}
saved, err := saveAttachments(mc, message, "downloads")
if err != nil {
log.Fatal(err)
}
for _, path := range saved {
fmt.Println("saved", path)
}
if err := mc.Messages().MarkRead(message.ID, true); err != nil {
log.Fatal(err)
}
}
The details that matter with real mail:
- The file name comes from the sender. A name like
../../.bashrcis a classic path-traversal trick.filepath.Basekeeps the last path component, and the index prefix keeps two files calledinvoice.pdfapart. Storedisfalsefor a part that had no body. Skip it.ContentIDmarks an inline image, the kind HTML shows with<img src="cid:logo">. Most pipelines want the PDF, not the logo.MimeTypeandSizelet you keep onlyapplication/pdf, or refuse anything over a size, before you download it.- Treat files as untrusted. Scan them, or open them in a sandbox, before anything else touches them.
That is the job a Go email parser does for attachments, without walking a MIME tree or decoding base64.
Wait for the next email in Go
WaitFor returns when a matching message arrives, opened. It is the shortest way to read a verification email in an end-to-end test, or to wait for a reply:
started := time.Now() // take the time before the email is triggered
// ...trigger the email here: submit a sign-up form, call your own API...
message, err := mc.Messages().WaitFor(mailcycle.WaitOptions{
AddressID: address.ID,
Subject: "verify",
Since: started,
Timeout: 2 * time.Minute,
})
if err != nil {
if mailcycle.ErrorCode(err) == "timeout" {
log.Fatal("no verification email within two minutes")
}
log.Fatal(err)
}
code := regexp.MustCompile(`\b(\d{6})\b`).FindStringSubmatch(message.Text)
if code == nil {
log.Fatalf("no code in: %q", message.Text)
}
fmt.Println("code:", code[1])
How it behaves:
Sinceis the important one. Mail received from that moment on counts, even if it landed before the wait began. Take the time before you trigger the email, so a fast delivery cannot slip past. It defaults to whenWaitForis called.FromandSubjectmatch text the sender or subject contains, ignoring case.AddressIDlimits the wait to one address.Timeoutis one minute by default. When it runs out you get an*APIErrorwithCodeset to"timeout".PollEvery(five seconds by default) is how often it checks when the live stream is not available.
In a test, create the address at the top and delete it when the test ends:
func newAddress(t *testing.T, mc *mailcycle.Client) mailcycle.Address {
t.Helper()
address, err := mc.Addresses().Create(mailcycle.NewAddress{Prefix: "test", RetentionDays: 1})
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = mc.Addresses().Delete(address.ID) })
return address
}
Mark as read, star, move and delete
These calls change state only, so they do not open any content:
| Call | What it does |
|---|---|
mc.Messages().MarkRead(id, true) |
Marks read. MarkRead(id, false) marks unread. |
mc.Messages().Star(id, true) |
Stars it. Star(id, false) unstars. |
mc.Messages().Move(id, "junk") |
Moves to "inbox", "junk" or "trash". |
mc.Messages().Delete(id) |
Deletes it now. |
Get new email pushed to Go with a webhook
Mailcycle can tell your service the moment mail arrives. A message.received event carries the message’s id and its address’s id. Your code fetches the message by id and opens it locally, so the phrase stays on your machine.
Add a webhook in the app under API, on the Webhooks tab, or from Go with a signed-in session:
hook, secret, err := mc.Webhooks().Create(
"https://example.com/hooks/mailcycle",
[]string{"message.received"},
"Inbound mail",
)
if err != nil {
log.Fatal(err)
}
fmt.Println(hook.ID, secret) // whsec_..., shown once: store it as MAILCYCLE_WEBHOOK_SECRET
The URL must be HTTPS. For local development, expose your dev server through a tunnel. Then the receiving handler, with the standard library’s ServeMux:
package main
import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"os"
"sync"
"mailcycle.email/go"
)
var (
secret = os.Getenv("MAILCYCLE_WEBHOOK_SECRET")
seen sync.Map // one process only: use a table with a unique key in production
)
func main() {
mc, err := mailcycle.SignIn(os.Getenv("MAILCYCLE_PHRASE"), mailcycle.Options{})
if err != nil {
log.Fatal(err)
}
mux := http.NewServeMux()
mux.HandleFunc("POST /hooks/mailcycle", func(w http.ResponseWriter, r *http.Request) {
raw, err := io.ReadAll(http.MaxBytesReader(w, r.Body, 1<<20)) // the exact body, before any parsing
if err != nil {
http.Error(w, "unreadable body", http.StatusBadRequest)
return
}
if !mailcycle.VerifyWebhookSignature(secret, raw, r.Header.Get("Mailcycle-Signature")) {
http.Error(w, "bad signature", http.StatusUnauthorized)
return
}
if id := r.Header.Get("Mailcycle-Event-Id"); id != "" {
if _, again := seen.LoadOrStore(id, true); again {
w.WriteHeader(http.StatusNoContent) // a retry of an event already handled
return
}
}
var event struct {
Type string `json:"type"`
Payload struct {
MessageID string `json:"messageId"`
} `json:"payload"`
}
if err := json.Unmarshal(raw, &event); err != nil {
http.Error(w, "bad json", http.StatusBadRequest)
return
}
w.WriteHeader(http.StatusNoContent) // answer fast, then do the work
if event.Type == "message.received" {
go process(mc, event.Payload.MessageID)
}
})
log.Fatal(http.ListenAndServe(":8080", mux))
}
func process(mc *mailcycle.Client, messageID string) {
message, err := mc.Messages().Get(messageID) // fetched by id, opened here
if err != nil || !message.Opened {
return
}
saved, _ := saveAttachments(mc, message, "downloads")
fmt.Printf("%s: %s (%d files)\n", message.FromAddress, message.Subject, len(saved))
_ = mc.Messages().MarkRead(message.ID, true)
}
saveAttachments is the function from the attachments section. What each part is for:
- The signature is an HMAC-SHA256 of the timestamp and the raw body, keyed with your
whsec_secret.VerifyWebhookSignaturechecks it in constant time and refuses a timestamp more than five minutes old. Check the bytes as they arrived: a body that was decoded and re-encoded will not match. - Answer fast. Mailcycle waits 10 seconds for a
2xx. The handler replies first and does the fetching and saving in a goroutine. - Deduplicate. An event can arrive more than once, and
Mailcycle-Event-Idis the same on every attempt. Thesync.Mapsuits one process. With several instances, insert the id into a table with a unique constraint. - Gin, Echo and Chi follow the same steps: read the raw body, verify, fetch by id.
You can test the handler without a live webhook. mailcycle.WebhookSignatureHeader(secret, body, timestamp) builds the header Mailcycle would send. Retries, the delivery log and every event type are in the webhooks guide, and Receive email with a webhook walks through the receiver in more depth.
Fan out with goroutines: one address per job
Go’s strength is running many things at once, and addresses are cheap to create, so a batch job can give every unit of work its own inbox. This pattern suits a test suite that runs your own sign-up, invite and reset flows side by side, or a batch job that handles many customer jobs at once.
func collectCodes(mc *mailcycle.Client, jobs []string) map[string]string {
var (
mu sync.Mutex
wg sync.WaitGroup
codes = make(map[string]string)
re = regexp.MustCompile(`\b\d{6}\b`)
)
for _, job := range jobs {
wg.Add(1)
go func(job string) {
defer wg.Done()
address, err := mc.Addresses().Create(mailcycle.NewAddress{Prefix: "job"})
if err != nil {
return
}
since := time.Now()
trigger(job, address.EmailAddress) // your code that causes the email
msg, err := mc.Messages().WaitFor(mailcycle.WaitOptions{
AddressID: address.ID, Since: since, Timeout: time.Minute,
})
if err != nil {
return
}
mu.Lock()
codes[job] = re.FindString(msg.Text)
mu.Unlock()
}(job)
}
wg.Wait()
return codes
}
Because every job waits on its own address, two goroutines can never read each other’s code. The Since value is taken just before trigger, so a fast delivery cannot slip past. If you run hundreds of jobs, cap the number in flight with a buffered channel or errgroup.SetLimit, so you stay inside the rate limit.
Run the receiver as a long-lived worker
A service that reads mail all day is a small loop with a clean shutdown. Open the event stream, handle each id as it arrives, and stop on a signal.
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
stream, err := mc.Events().Stream(nil)
if err != nil {
log.Fatal(err)
}
go func() { <-ctx.Done(); stream.Close() }()
for {
event, ok := stream.Next(0)
if !ok {
break
}
if event.Type == "message.received" {
handle(event) // fetch by id, open locally, act
}
}
Run it as a systemd unit or a container with a restart policy. Events carry ids and never content, and a dropped stream does not replay, so refetch the newest messages with mc.Messages().List(addressID, mailcycle.ListOptions{}) when StreamHooks.OnReconnect fires. Keep the recovery phrase in the unit’s environment file and let mailcycle.Resume() pick up the session token between restarts, so a crash loop does not sign in every few seconds.
Table-driven tests for an email handler
Go tests read well as tables. Keep the parsing in a pure function that takes the message text, and test it with plain strings. Save the live inbox for one end to end test.
func TestExtractCode(t *testing.T) {
cases := []struct{ name, body, want string }{
{"plain", "Your code is 482913", "482913"},
{"with text around", "Use 105977 to sign in. It expires soon.", "105977"},
{"no code", "Welcome aboard", ""},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
if got := extractCode(c.body); got != c.want {
t.Fatalf("got %q, want %q", got, c.want)
}
})
}
}
For the webhook handler, build the signed request with httptest.NewRequest, post it to the handler with httptest.NewRecorder and assert on the status. A request with a wrong signature should return 401, and one with a valid signature should return 200 and run your handler once. Gate the live test behind an environment variable so go test ./... stays fast on a laptop and runs the full flow in CI.
Build a small CLI with the receiving half
Many Go teams ship a command-line tool next to the service. A twenty line main that creates an address, prints it and waits turns the SDK into a tool for support staff: inbox wait --subject receipt prints the receipt text and saves the PDF to the current folder. Read the phrase from the environment, accept --subject and --timeout flags with the standard flag package, and exit with a non-zero code when mailcycle.ErrorCode(err) returns "timeout", so a shell script can branch on it. Cross-compile the binary with GOOS and GOARCH and hand it to the people who need it.
Reading the inbox in a Go HTTP handler
A handler that shows the latest messages for support staff is a short function. Take a context.Context from the request for your own timeouts, call mc.Messages().List(address.ID, mailcycle.ListOptions{Limit: 20}), and render SafeHTML into the page only inside a sandboxed iframe. Cache the page for a few seconds with a plain sync.Mutex and a timestamp, so a busy dashboard does not call the API on every refresh.
An IMAP client and an email API in Go
Go has no IMAP client in the standard library. Packages such as go-imap connect to a mailbox: you give them a host, port 993 and credentials, select the inbox, fetch messages and parse the MIME with net/mail or a library.
An email API fits when your program needs addresses of its own: one per customer, per test run or per agent, created in code, with mail pushed to you as it arrives.
| An IMAP client such as go-imap | Mailcycle Go SDK | |
|---|---|---|
| Install | A third-party module | go get mailcycle.email/go |
| You need | An IMAP mailbox and its credentials | A recovery phrase, plus an API key if you want one |
| New addresses | Made at your mail provider | mc.Addresses().Create() in code |
| Parsing | Raw MIME, parsed by you | Parsed fields: Text, HTML, Attachments |
| Tracker-free HTML | Strip it yourself | SafeHTML, with Blocked listing what was removed |
| Attachments | Walk the MIME parts | mc.Messages().Attachment(message, index) |
| New-mail push | IMAP IDLE | Webhooks and mc.Events().Stream() |
| Wait for one email | Write the loop yourself | WaitFor() |
| Mail at rest | Depends on the provider | Encrypted with keys from your recovery phrase |
Troubleshooting
- Messages have
Openedset tofalseand empty fields. The client has no phrase, or a phrase from a different account. Build it withmailcycle.SignIn(phrase, ...). - Nothing arrives at a new address. Check
address.Receivesinmc.Addresses().List(), and check the sender used the exact address, since prefixed names have a random ending. mailcycle.ErrorCode(err)returnsrate_limited. You are reading too much too fast. Back off, read only what is new, or switch to webhooks.- A 404 fetching an attachment. The part has
Storedset tofalse. Skip it. - The webhook handler returns 401 for real deliveries. You are verifying a re-encoded body, or the wrong secret. Use the raw request bytes and the
whsec_secret of this webhook.
Every error code is listed in Errors.
Reply from Go, or hand the inbox to an agent
To answer a message in the same thread, set InReplyTo on a mailcycle.Outgoing and call mc.Messages().Send(). Sending email from Go covers that, along with the plans that send.
If an AI agent should read the inbox, Mailcycle also runs as an MCP server with tools such as wait_for_message, read_message and read_attachment, for Claude Code, Cursor, Codex or any other MCP client. Start with Give your AI agent its own email inbox.
Next steps
- Read the Go SDK page and the full Go SDK guide, and Reading mail for folders, paging and attachments at the API level.
- See Encryption and sealed data and the security page.
- Send as well as receive with How to send email from Go, including HTML email from Go templates and a reusable mailer package, or the same flow in another language.
- Everything for developers is on the developers page, and the plans are on pricing.
FAQ
How do I receive email in Go?
Give your program an address that receives mail, then read it with a client. With Mailcycle, run go get mailcycle.email/go, sign in with mailcycle.SignIn(phrase, mailcycle.Options{}), create an address with mc.Addresses().Create(), and call mc.Messages().WaitFor(). The message comes back parsed and decrypted: sender, subject, text, HTML and attachments.
How do I read emails from an inbox in Go?
Call mc.Messages().List(addressID, mailcycle.ListOptions{Limit: 20}) for one page, newest first, or mc.Messages().All(addressID, "inbox") to walk the whole folder. Each Message has FromAddress, Subject, Text, SafeHTML, Attachments and Read.
How do I download email attachments in Go?
Each Message lists its files in message.Attachments, with Filename, MimeType, Size and Index. Call mc.Messages().Attachment(message, attachment.Index) to get a []byte, opened on your machine, and write it with os.WriteFile. Clean the file name first with filepath.Base, because it comes from the sender.
How can a Go program wait for a new email?
Call mc.Messages().WaitFor(mailcycle.WaitOptions{AddressID: ..., Subject: ..., Since: ..., Timeout: ...}). It returns the first matching message. If nothing matches in time it returns an *APIError with Code set to "timeout", which mailcycle.ErrorCode(err) reads for you.
How do I get notified when an email arrives in a Go web service?
Add a webhook for message.received, point it at a net/http handler, and check each delivery with mailcycle.VerifyWebhookSignature() against the raw body. The event carries the message id, so fetch the message with mc.Messages().Get(). Webhooks are on the Operator plan and above.
Is there a Go library to read email without IMAP?
Yes. The Mailcycle Go SDK reads mail over HTTPS, so there is no IMAP host, port or mailbox password, and the message arrives already parsed.
Which Mailcycle plan do I need to receive email from Go?
Every plan can create addresses, read mail and download attachments when the program signs in with the recovery phrase. API keys and webhooks start at Operator. See Plans and limits.
Where does the recovery phrase for the Go SDK come from?
It is the account. Make a free account at https://app.mailcycle.email/operator/signup and keep the twelve words it shows, or call mailcycle.CreateAccount("", mailcycle.Options{}) from Go, which returns a new client and its phrase. Save the phrase to a file only you can read, then export MAILCYCLE_PHRASE from it. If the variable is unset, v0.11.0 of the SDK says so and names MAILCYCLE_PHRASE.
What happens when WaitFor times out in Go?
It returns an *APIError with Code set to "timeout", and the message says how long it waited and to set WaitOptions.Timeout to wait longer. The default is one minute. Check it with mailcycle.ErrorCode(err) == "timeout" to tell an empty wait from a real failure.
Why does the Go client need my recovery phrase?
Mail is encrypted the moment it arrives, with keys from your recovery phrase. The Go client derives the same keys on your machine and opens each message in your process. A message that does not open comes back with Opened set to false.
Related
Receive email in code
- AgentMail Alternative for AI Agent Inboxes (AgentMail alternative)
- CloudMailin Alternative: Inbound Email to Rails With an Address per API Call (CloudMailin alternative)
- Mailgun Inbound Routes Alternative: Route Mail by Address, Not Regex (Mailgun Routes alternative)
- Mailosaur Alternative for Email Testing and Test Inboxes (Mailosaur alternative)
- Mailparser and Parseur Alternative: Incoming Email as JSON on a Webhook (Mailparser and Parseur alternative)
- MailSlurp Alternative for Email Testing and Test Inboxes (MailSlurp alternative)
- Mailtrap Alternative for Email Testing and Test Inboxes (Mailtrap alternative)
- Postmark Inbound Alternative: Addresses by API, Signed Webhooks (Postmark inbound alternative)
- Resend Inbound Alternative: An Address per API Call, Signed Events (Resend inbound alternative)
- SendGrid Inbound Parse Alternative: Inbound Email by API Call (SendGrid Inbound Parse alternative)
- Testmail.app Alternative for Email Testing and Test Inboxes (Testmail.app alternative)
- Test Email Flows on Real Devices with Appium: Read Sign-Up Codes in Python (Appium)
- How to Give a Browser Use Agent an Email Address and Let It Read Its Own Verification Code (Browser Use sign-ups)
- How to Receive Email in C#: Read the Inbox, Save Attachments and Get New Mail Pushed (C# / .NET)
- How to Test Email Verification in Cypress: Receive Sign-Up Codes with cy.task (Cypress)
- Ethereal Email Alternative: Test Nodemailer Emails with an Address per Test (Ethereal Email alternative)
- How to Read Email in Java: Read the Inbox, Save Attachments and Receive Mail in Spring Boot (Java)
- How to Receive Email in PHP with an Email API: Read the Inbox, Save Attachments and Handle Webhooks (PHP / Laravel)
- How to Receive Email in Python: Read the Inbox, Save Attachments and Get New Mail Pushed (Python)
- Receive Email in Ruby and Rails: Read the Inbox, Save Attachments and Handle Webhooks (Ruby)
- How to Receive Email in Rust: Read the Inbox, Save Attachments and Handle Webhooks in Axum (Rust)
- Add Inbound Email to Your SaaS: Support Intake and Reply-by-Email (SaaS support)
- How to Verify Email in Selenium Tests: Read Sign-Up Codes with Python and pytest (Selenium)
- How to Handle Email Verification in a Stagehand Browser Agent: Create an Address, Wait for the Code, Delete It (Stagehand sign-ups)
- How to Receive Email in Swift: Read the Inbox, Save Attachments and Handle Vapor Webhooks (Swift)
- Test Accounts for Security Testing: a Separate Email Address per Program (Test accounts for security testing)
- How to Automate Email Verification in Tests with Playwright: OTP Codes, Magic Links and Password Resets (Testing email verification)
- How to Receive Email in Node.js: Read the Inbox, Save Attachments and Handle Webhooks (TypeScript / Node.js)
- How to Receive Email with a Webhook: Inbound Email to Your HTTP Endpoint (Webhooks)