Skip to content

mailproto/smtpd

Repository files navigation

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

About

A Golang library for implementing RFC2821 SMTP servers

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages