Skip to content

A lightweight Go wrapper for the Mail.gw temporary email service API, providing programmatic access to disposable email

License

Notifications You must be signed in to change notification settings

fisherangela73/mailgw-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mailgw-go

A lightweight and feature-complete Go wrapper for the Mail.gw API, providing easy access to temporary email services.

Installation

go get github.com/fisherangela73/mailgw-go

Quick Start

package main

import (
    "fmt"
    "github.com/fisherangela73/mailgw-go/pkg/mailgw"
)

func main() {
    // Create a new client
    client := mailgw.NewClient()

    // Get available domains
    domains, _ := client.GetDomains()
    
    // Create a temporary email account
    account, _ := client.CreateAccount("test@"+domains[0].Domain, "password123")
    
    // Login
    client.Login(account.Address, "password123")
    
    // Check for new messages
    message, err := client.GetLastMessage()
    if err == nil {
        fmt.Printf("New message: %s\n", message.Subject)
    }
}

Features

  • 🚀 Complete Mail.gw API coverage
  • 💡 Simple and intuitive interface
  • 📦 Zero external dependencies
  • ✨ Fully typed responses
  • ⚙️ Configurable client

API Reference

Creating a Client

// Default client
client := mailgw.NewClient()

// Custom configuration
client := mailgw.NewClient(
    mailgw.WithBaseURL("https://custom.mail.gw"),
    mailgw.WithToken("your-token"),
)

Account Operations

// Create account
account, err := client.CreateAccount("address@domain.com", "password")

// Login
err := client.Login("address@domain.com", "password")

// Get account details
me, err := client.GetMe()

// Delete account
err := client.DeleteAccount("account-id")

Message Operations

// Get all messages
messages, err := client.GetMessages()

// Get latest message
message, err := client.GetLastMessage()

// Get specific message
message, err := client.GetMessage("message-id")

// Mark as read
err := client.MarkMessageAsRead("message-id")

// Delete message
err := client.DeleteMessage("message-id")

Domain Operations

// Get available domains
domains, err := client.GetDomains()

// Get specific domain
domain, err := client.GetDomain("domain-id")

Error Handling

The client returns appropriate errors for various scenarios:

  • Network errors
  • Authentication errors (401)
  • Rate limiting (429)
  • Invalid requests (400)
  • Not found errors (404)

Examples

Check the examples directory for more detailed usage examples.

Contributing

Contributions are welcome! Feel free to submit a Pull Request.

License

MIT License - see LICENSE for details.

About

A lightweight Go wrapper for the Mail.gw temporary email service API, providing programmatic access to disposable email

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages