65 lines
1.8 KiB
Go
65 lines
1.8 KiB
Go
|
// Copyright (c) 2025 H0llyW00dzZ All rights reserved.
|
||
|
//
|
||
|
// By accessing or using this software, you agree to be bound by the terms
|
||
|
// of the License Agreement, which you can find at LICENSE files.
|
||
|
|
||
|
// Package export provides functionality to export email messages
|
||
|
// in various formats. It defines interfaces and implementations
|
||
|
// for exporting messages, allowing flexibility in how messages
|
||
|
// are written to different outputs.
|
||
|
//
|
||
|
// # Features
|
||
|
// - Define a standard interface for exporting messages
|
||
|
// - Implement JSON export functionality with customizable encoding
|
||
|
//
|
||
|
// # Usage
|
||
|
//
|
||
|
// JSON Export Example:
|
||
|
//
|
||
|
// package main
|
||
|
//
|
||
|
// import (
|
||
|
// "log"
|
||
|
// "os"
|
||
|
//
|
||
|
// "git.b0zal.io/H0llyW00dzZ/imap/client"
|
||
|
// "git.b0zal.io/H0llyW00dzZ/imap/export"
|
||
|
// )
|
||
|
//
|
||
|
// func main() {
|
||
|
// config := &client.Config{
|
||
|
// Username: "user@example.com",
|
||
|
// Password: "password",
|
||
|
// Server: "imap.example.com:993",
|
||
|
// InsecureSkipVerify: true,
|
||
|
// }
|
||
|
//
|
||
|
// imapClient := client.NewIMAP(config)
|
||
|
//
|
||
|
// err := imapClient.Connect()
|
||
|
// if err != nil {
|
||
|
// log.Fatalf("Failed to connect: %v", err)
|
||
|
// }
|
||
|
// defer imapClient.Disconnect()
|
||
|
//
|
||
|
// messageConfig := client.MessageConfig{
|
||
|
// GrabID: true,
|
||
|
// GrabFrom: true,
|
||
|
// GrabSubject: true,
|
||
|
// GrabBody: true,
|
||
|
// }
|
||
|
//
|
||
|
// file, err := os.Create("messages.json")
|
||
|
// if err != nil {
|
||
|
// log.Fatalf("Failed to create file: %v", err)
|
||
|
// }
|
||
|
// defer file.Close()
|
||
|
//
|
||
|
// exporter := &export.JSONExporter{Encoder: export.DefaultJSONEncoder}
|
||
|
// err = imapClient.ExportMessagesTo(file, exporter, "INBOX", 10, messageConfig)
|
||
|
// if err != nil {
|
||
|
// log.Fatalf("Failed to export messages: %v", err)
|
||
|
// }
|
||
|
// }
|
||
|
package export
|