maildir

package module
v0.0.0-...-96c8878 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2017 License: ISC Imports: 10 Imported by: 2

README

PACKAGE

package maildir

This package is used for writing mails to a maildir, according to the specification located at http://www.courier-mta.org/maildir.html

TYPES

   type Maildir struct {
       // The root path ends with a /, others don't, so we can have 
       // the child of a maildir just with path + "." + encodedChildName.
       Path string
   }

Represent a folder in a maildir. The root folder is usually the Inbox.

func New(path string, create bool) (m *Maildir, err os.Error)

Same as the New function, but with the ability to control permissions. perm is an octal used for os.Chmod and what will be applied on files. For directories only: an additional chmod +x will be added for every r permission in user/group/other to make the directory accessible.

uid and gid are for os.Chown, pass DoNotSetOwner constant to ignore.

NewWithPerm(path string, create bool, perm os.FileMode, uid, gid int) (m *Maildir, err error)

Open a maildir. If create is true and the maildir does not exist, create it.

func (m *Maildir) Child(name string, create bool) (*Maildir, os.Error)

Get a subfolder of the current folder. If create is true and the folder does not exist, create it.

func (m *Maildir) CreateMail(data io.Reader) (filename string, err os.Error)

Write a mail to the maildir folder. The data is not encoded or compressed in any way.

Fuzz test

There's a fuzz test for the encodeName() function.

To prepare, run:

$ go-fuzz-build github.com/flashmob/go-maildir

it will take a while...

then start like this:

$ go-fuzz -bin=maildir-fuzz.zip -workdir=workdir -procs=8

where procs is the number of CPU cores to use. The test will run in parallel and it will produce some stats.

Read more about these stats here https://github.com/dvyukov/go-fuzz

After running the test, go to the ./wokrdir and inspect your crashes & commit any new corpus

Documentation

Overview

This package is used for writing mails to a maildir, according to the specification located at http://www.courier-mta.org/maildir.html

Index

Constants

View Source
const DefaultFilePerm = 0600

Default file perms for files. For directories u+x will be added

View Source
const DoNotSetOwner = -1

Variables

This section is empty.

Functions

This section is empty.

Types

type Maildir

type Maildir struct {
	// The root path ends with a /, others don't, so we can have
	// the child of a maildir just with path + "." + encodedChildName.
	Path string
	// contains filtered or unexported fields
}

Represent a folder in a maildir. The root folder is usually the Inbox.

func New

func New(path string, create bool) (m *Maildir, err error)

Open a maildir. If create is true and the maildir does not exist, create it.

func NewWithPerm

func NewWithPerm(path string, create bool, perm os.FileMode, uid, gid int) (m *Maildir, err error)

Same as New, but ability to control permissions perm is an octal used for os.Chmod and what will be used for files for directories, an additional chmod u+x will be applied. uid and gid are for os.Chown, pass DoNotSetOwner constant to ignore.

func (*Maildir) Child

func (m *Maildir) Child(name string, create bool) (*Maildir, error)

Get a subfolder of the current folder. If create is true and the folder does not exist, create it.

func (*Maildir) CreateMail

func (m *Maildir) CreateMail(data io.Reader) (filename string, err error)

Write a mail to the maildir folder. The data is not encoded or compressed in any way.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL