Documentation ¶
Overview ¶
Package maildir provide a library to manage message (email), and its folder, using maildir format.
This library use the following file name format for tmp message,
epoch ".M" usec "_P" pid "_Q" counter "." hostname
and the following format for new message,
epoch ".M" usec "_P" pid "_V" dev "_I" inode "_Q" counter "." hostname ",S=" size ":2"
The epoch is Unix timestamp--number of elapsed seconds, usec is the 6 digits of micro seconds, pid is the process ID of the program, dev is the file device number, inode is the file inode number, counter is a auto increment number start from 0, hostname is the system host name, and size is the message size.
References,
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Folder ¶ added in v0.47.0
type Folder struct {
// contains filtered or unexported fields
}
Folder is a directory under maildir that store messages per file. A folder contains three directories: tmp, new, and cur; and an empty file "maildirfolder" to indicate a directory is a folder.
func CreateFolder ¶ added in v0.47.0
CreateFolder create folder under directory maildir, populate all required sub directories and file. A folder must start with dot '.' and does not contains unicode control character.
func NewFolder ¶ added in v0.47.0
NewFolder initialize folder from directory maildir. It will return an error if the one of the directory is not exist or does not have permission to write, or "maildirfolder" file is not exist.
func (*Folder) Delete ¶ added in v0.47.0
Delete hard delete a message file in "cur". It will return no error if the file does not exist.
type Manager ¶
type Manager struct { // Folder embeded as the main maildir. Folder // contains filtered or unexported fields }
Manager manage messages and folders in single file system. This is the main Maildir.
func NewManager ¶ added in v0.47.0
NewManager create new maildir Manager in directory and initialize the hostname, pid, and counter for generating unique name.
func (*Manager) Incoming ¶
Incoming save message received from external MTA in directory "${dir}/tmp/${unique}". Upon success, hard link it to "${dir}/new/${unique}" and delete the temporary file, and return the path of new file.
func (*Manager) OutgoingQueue ¶ added in v0.47.0
OutgoingQueue save the message in temporary queue directory before sending it to external MTA or processed.
When mail is coming from MUA and received by server, the mail need to be successfully stored into disk by server, before replying with "250 OK" to client.
On success it will return the file name.