Go client for creating temporary test email accounts on Ethereal Email using Nodemailer's provisioning API. Useful for automated tests and CI without needing real mail accounts.
- Creates test SMTP, IMAP, and POP3 credentials in a single HTTP request
- Standard library integration with helpers for
smtp.PlainAuthand"host:port"formatting - Host and address checkers to detect Ethereal email domains
- Web preview URL generator for message IDs
- Standard library only, no third-party dependencies
go get github.com/fumbledlol/ethereal-gopackage main
import (
"context"
"fmt"
"net/smtp"
"github.com/fumbledlol/ethereal-go"
)
func main() {
ctx := context.Background()
// Provision new credentials
acc, err := ethereal.CreateAccount(ctx)
if err != nil {
panic(err)
}
fmt.Printf("User: %s\n", acc.User)
fmt.Printf("Web inbox: %s\n", acc.Web)
// Send an email with net/smtp
msg := []byte("To: recipient@example.com\r\nSubject: Test Email\r\n\r\nHello from Ethereal.")
err = smtp.SendMail(
acc.SMTPAddr(),
acc.Auth(),
acc.User,
[]string{"recipient@example.com"},
msg,
)
if err != nil {
panic(err)
}
fmt.Println("Message sent. Check web inbox link above.")
}ethereal.IsEtherealHost("smtp.ethereal.email") // true
ethereal.IsEtherealAddress("steve@ethereal.email") // trueBenchmarkIsEtherealAddress-12 75256341 17.71 ns/op 0 B/op 0 allocs/op
BenchmarkIsEtherealHost-12 55537813 20.12 ns/op 0 B/op 0 allocs/op