Futuristic SMTP INBOUND-only server for home usage.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

30 lines
641 B

package main
import (
"bytes"
"log"
"net"
)
func mailHandler(origin net.Addr, from string, to []string, data []byte) {
SmtpSession := new(Session)
log.Printf("Received mail from %s for %q from %s", from, to, origin.String())
log.Println(" Recipients: ", to)
for _, rcptTo := range to {
SmtpSession.Reset()
if rcptErr := SmtpSession.Rcpt(rcptTo); rcptErr == nil {
SmtpSession.MailFrom = from
if dataErr := SmtpSession.Data(bytes.NewReader(data)); dataErr != nil {
log.Println("Problem Saving Message: ", dataErr.Error())
}
log.Println("Session is: ", SmtpSession)
} else {
log.Println(rcptErr)
}
}
}