示例#1
0
func main() {
	// This server listens on two different ports

	s := imap.NewServer(
		imap.ListenOption("127.0.0.1:1193"),
		imap.ListenOption("127.0.0.1:1194"),
	)

	err := s.Start()
	if err != nil {
		log.Print("IMAP server not started")
	}
}
示例#2
0
func main() {
	// This server uses boltDb for its authentication, adding a test user

	// Create a file for the BoltAuthStore - in production this should probably NOT be a temporary file (!)
	tmpFile, err := ioutil.TempFile("", "imap_")
	if err != nil {
		log.Fatalln("Could not create tempfile:", err)
	}

	// Initialize authentication backend
	a, err := boltstore.NewBoltAuthStore(tmpFile.Name())
	if err != nil {
		log.Fatalln("Could not create BoltAuthStore:", err)
	}

	// Add a user
	a.CreateUser("*****@*****.**", "password")

	// Put everything together
	s := imap.NewServer(
		imap.ListenOption("127.0.0.1:1193"),
		imap.AuthStoreOption(a),
	)

	// Firing up the server
	err = s.Start()
	if err != nil {
		log.Print("IMAP server not started")
	}
}
示例#3
0
func main() {
	// This server listens on two different ports, one of which allows STARTTLS

	s := imap.NewServer(
		imap.ListenOption("127.0.0.1:1193"), // optionally also listen to non-STARTTLS ports
		imap.ListenSTARTTLSOoption("127.0.0.1:1194", "demo/starttls/public.pem", "demo/starttls/private.pem"),
	)

	fmt.Println("Starting server, you can test by doing:\n",
		"$ telnet localhost 1193\n",
		"or\n",
		"$ openssl s_client -starttls imap -crlf -connect 'localhost:1194'")

	err := s.Start()
	if err != nil {
		log.Print("IMAP server not started")
	}
}