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 ¶
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error)
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
Click to show internal directories.
Click to hide internal directories.