H0llyW00dzZ
4c74ebc1c7
- [+] feat(config.go): add error variables for client connection and body reading failures - [+] refactor(export_messages.go, list_mailboxes.go, list_messages.go): replace error messages with new error variables Reviewed-on: #16 Co-authored-by: H0llyW00dzZ <h0llyw00dzz@pm.me> Co-committed-by: H0llyW00dzZ <h0llyw00dzz@pm.me>
50 lines
1.2 KiB
Go
50 lines
1.2 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 client
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/emersion/go-imap/client"
|
|
)
|
|
|
|
// Config holds the configuration for the IMAP client
|
|
type Config struct {
|
|
Username string
|
|
Password string
|
|
Server string
|
|
InsecureSkipVerify bool
|
|
}
|
|
|
|
// MessageConfig defines what parts of the message to retrieve
|
|
type MessageConfig struct {
|
|
GrabID bool
|
|
GrabFrom bool
|
|
GrabSubject bool
|
|
GrabBody bool
|
|
GrabSender bool
|
|
GrabReplyTo bool
|
|
GrabTo bool
|
|
GrabCc bool
|
|
GrabBcc bool
|
|
GrabInReplyTo bool
|
|
GrabDate bool
|
|
}
|
|
|
|
// IMAPClient represents an IMAP client
|
|
type IMAPClient struct {
|
|
config *Config
|
|
client *client.Client
|
|
}
|
|
|
|
var (
|
|
// ErrorsClientIsNotConnected is returned when an operation is attempted on a client that is not connected.
|
|
ErrorsClientIsNotConnected = errors.New("client is not connected")
|
|
|
|
// ErrorsFailedToReadBody is returned when there is a failure in reading the body of a message.
|
|
ErrorsFailedToReadBody = errors.New("failed to read body")
|
|
)
|