Library to develop email-based bots. Sync an IMAP folder and process emails. Record processing steps in sidecar files.
Library to develop email-based bots.
This library syncs an IMAP folder to disk, and then calls processing functions separately on new and all emails.
It can record its steps in YAML sidecar files next to each email. It uses flock
to lock processing steps.
github.com/JohannesEbke/go-imap-sync
package main
import (
"log"
"time"
"github.com/JohannesEbke/emailbot"
)
func main() {
emailbot.Main(addDownloadedRecord, printDetails)
}
func addDownloadedRecord(_ string, data emailbot.SidecarData) (*emailbot.Record, error) {
return &emailbot.Record{Time: time.Now(), Key: "synced"}, nil
}
func printDetails(emailFile string, data emailbot.SidecarData) (*emailbot.Record, error) {
log.Printf("%s: %v", emailFile, data)
return nil, nil
}