Files
mailblog/mailblog.go
Laurent Ulrich a559784462 Semble compliqué
2025-07-28 15:52:55 +02:00

43 lines
686 B
Go

package main
import (
"log"
"net/http"
"net/url"
"os"
"strings"
)
func slash(w http.ResponseWriter, r *http.Request) {
}
func main() {
var mb MailBox
url, err := url.Parse(os.Getenv("MAILBOX"))
if err != nil {
log.Fatal("Bad parameter MAILBOX:", os.Getenv("MAILBOX"), "(", err, ")")
}
mb.Server = url.Host
mb.User = os.Getenv("IMAP_USER")
mb.Password = os.Getenv("IMAP_PASSWORD")
mb.InBox, _ = strings.CutPrefix(url.Path, "/")
err = mb.Connect()
if err != nil {
log.Fatal(err)
}
msg, err := mb.ListMessages()
if err != nil {
log.Fatal(err)
}
log.Println(msg)
mb.Close()
return
http.HandleFunc("/", slash)
http.ListenAndServe("0.0.0.0:8080", nil)
}