Skip to content

regnull/popgun

 
 

Repository files navigation

POPgun

Build Status Coverage Status Go Report Card

POPgun is a lightweight POP3 server implementation in Go. POPgun meets RFC1939 and was mainly created for develmail.com.

Cloned from github.com/DevelHell/popgun, with added support for TLS connections and TOP command

Getting Started

POPgun is meant to be used as a package and you need to create your own implementations of Authorizator and Backend interfaces.

1. Import the POPgun package

import (
    "github.com/DevelHell/popgun"
)

2. Implement Authorizator and Backend interfaces

Authorizator is used for user authorization and there's only one function Authorize(user, pass string). Be aware that single instance is shared across all client connections.

Backend is used for mail storage access, e.g. database storage. Single Backend instance is shared across all client connections connections as well.

Example dummy implementations can be found in backend package, see comments in these files for more information. When your're done, create an instance of both of them:

backend := backends.DummyBackend{}
authorizator := backends.DummyAuthorizator{}

3. Configure and run the server

There is only one configuration field for now - ListenInterface, which defines interface (ip address) and port to listen on. Server is started in separate go routine, so be sure to keep the server busy, e.g. using wait groups:

cfg := popgun.Config{
    ListenInterface: "localhost:1100",
}

var wg sync.WaitGroup
wg.Add(1)

server := NewServer(cfg, authorizator, backend)
err := server.Start()
// If you want to use TLS instead of unencrypted connection, do this instead:
// err := server.StartTLS(certFile, keyFile)
if err != nil {
    log.Fatal(err)
    return
}
wg.Wait()

Server is logging to stderr using log package.

License and Contribution

POPgun is released under MIT license. Feel free to fork, redistribute or contribute!

About

POP3 server written in go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%