mailpit

package module
v0.44.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package mailpit provides a Testcontainers module for Mailpit, a fast multi-platform email testing tool with an SMTP server, web UI, and REST API.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithMessageLimit

func WithMessageLimit(limit int) testcontainers.CustomizeRequestOption

WithMessageLimit sets the maximum number of messages to keep in Mailpit. When the limit is reached the oldest messages are deleted.

func WithSMTPAuth

func WithSMTPAuth(user, password string) testcontainers.CustomizeRequestOption

WithSMTPAuth configures SMTP authentication credentials. It sets MP_SMTP_AUTH to "user:password" and enables insecure (plaintext) authentication via MP_SMTP_AUTH_ALLOW_INSECURE so that credentials are accepted over an unencrypted connection.

Types

type Container

type Container struct {
	testcontainers.Container
}

Container represents the Mailpit container type used in the module

func Run

Run creates an instance of the Mailpit container type

Example
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/testcontainers/testcontainers-go"
	"github.com/testcontainers/testcontainers-go/modules/mailpit"
)

func main() {
	// runMailpitContainer {
	ctx := context.Background()

	mailpitContainer, err := mailpit.Run(ctx, "axllent/mailpit:v1.20")
	defer func() {
		if err := testcontainers.TerminateContainer(mailpitContainer); err != nil {
			log.Printf("failed to terminate container: %s", err)
		}
	}()
	if err != nil {
		log.Printf("failed to start container: %s", err)
		return
	}
	// }

	state, err := mailpitContainer.State(ctx)
	if err != nil {
		log.Printf("failed to get container state: %s", err)
		return
	}

	fmt.Println(state.Running)

}
Output:
true

func (*Container) HTTPURL

func (c *Container) HTTPURL(ctx context.Context) (string, error)

HTTPURL returns the URL of the Mailpit HTTP interface and REST API, using the 8025/tcp port.

func (*Container) SMTPEndpoint

func (c *Container) SMTPEndpoint(ctx context.Context) (string, error)

SMTPEndpoint returns the SMTP endpoint of the Mailpit container, in the form "host:port" using the 1025/tcp port.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL