Created
October 4, 2013 23:36
-
-
Save dtjm/6834557 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"github.com/bradfitz/go-smtpd/smtpd" | |
"log" | |
"time" | |
) | |
var addr = flag.String("addr", ":25", "listen address") | |
// Just dump the mail | |
func onNewMail(c smtpd.Connection, from smtpd.MailAddress) (env smtpd.Envelope, err error) { | |
log.Printf("%v %v", c.Addr(), from) | |
env = new(smtpd.BasicEnvelope) | |
env.AddRecipient(from) | |
return | |
} | |
func main() { | |
flag.Parse() | |
server := smtpd.Server{ | |
Addr: *addr, | |
Hostname: "", // use system hostname | |
ReadTimeout: 60 * time.Second, | |
WriteTimeout: 60 * time.Second, | |
PlainAuth: false, | |
OnNewMail: onNewMail, | |
} | |
log.Printf("Listening on %s", *addr) | |
err := server.ListenAndServe() | |
if err != nil { | |
log.Printf("Failed to start server: %s", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment