Categorygithub.com/mailproto/smtpd
repositorypackage
0.0.0-20230308042129-1ff1a6de0479
Repository: https://github.com/mailproto/smtpd.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

Build Status

smtpd

smtpd is a pure Go implementation of an SMTP server. It allows you to do things like:

package main

import (
    "fmt"
    "net/smtp"

    "github.com/mailproto/smtpd"
)

var helloWorld = `To: [email protected]
From: [email protected]
Content-Type: text/plain

This is the email body`

func main() {
    var server *smtpd.Server
    server = smtpd.NewServer(func(msg *smtpd.Message) error {
        fmt.Println("Got message from:", msg.From)
        fmt.Println(string(msg.RawBody))
        return server.Close()
    })

    go server.ListenAndServe(":2525")
    <-server.Ready

    log.Fatal(smtp.SendMail(server.Address(), nil, "[email protected]", []string{"[email protected]"}, []byte(helloWorld)))
}


@todo document