first commit

This commit is contained in:
Laurent Ulrich
2025-07-27 20:31:33 +02:00
commit 6feda8eec1
4 changed files with 111 additions and 0 deletions

32
imap_handler.go Normal file
View File

@@ -0,0 +1,32 @@
package main
import (
"log"
"mime"
"github.com/emersion/go-imap/v2/imapclient"
"github.com/emersion/go-message/charset"
)
type MailBox struct {
Server string
Client *imapclient.Client
}
func (mb *MailBox) ListMessages() (string, error) {
return "", nil
}
func (mb *MailBox) Connect() error {
options := &imapclient.Options{
WordDecoder: &mime.WordDecoder{CharsetReader: charset.Reader},
}
var err error
mb.Client, err = imapclient.DialStartTLS(mb.Server, options)
if err != nil {
log.Println("Error connnecting to", mb.Server, ":", err)
return err
}
return nil
}