Documentation
¶
Index ¶
- Constants
- func Encrypt_Password(password string, salt []byte) string
- func FormatDate(date time.Time) string
- func MIMEHeaderToString(header textproto.MIMEHeader) string
- func MimeBodyDecode(str string, charset string, encoding string) string
- func MimeHeaderDecode(str string) string
- func ParseMIME(MIMEBody *MIMEBody, reader io.Reader, boundary string, message *Message) error
- func Partbuf(reader io.Reader) (int64, []byte, error)
- func SplitParams(params string) []string
- func Validate_Password(hashed string, input_password string) bool
- func WriteMIMEHeader(writer io.Writer, header textproto.MIMEHeader) (n int, err error)
- type Attachment
- type ComposeForm
- type Content
- type ContentQuery
- type DataStore
- func (ds *DataStore) CheckGreyHost(h string) bool
- func (ds *DataStore) CheckGreyMail(t, m, d, h string) bool
- func (ds *DataStore) Login(u string, p string) (*User, error)
- func (ds *DataStore) MessageSetBySequenceNumber(username string, set SequenceSet) Messages
- func (ds *DataStore) MessageSetByUID(username string, set SequenceSet) Messages
- func (ds *DataStore) MessageSetFlags(username string, seq string)
- func (ds *DataStore) NextId(table string) int
- func (ds *DataStore) Pop3GetDele(username string, sequence int) error
- func (ds *DataStore) Pop3GetList(username string) (Messages, error)
- func (ds *DataStore) Pop3GetRetr(username string, sequence int) (Message, error)
- func (ds *DataStore) Pop3GetStat(username string) (int, int, error)
- func (ds *DataStore) Pop3GetUidl(username string) (Messages, error)
- func (ds *DataStore) Recent(username string) int
- func (ds *DataStore) RemoveRecent(m Message)
- func (ds *DataStore) SaveMail()
- func (ds *DataStore) SaveSpamIP(ip string, email string)
- func (ds *DataStore) StorageConnect()
- func (ds *DataStore) StorageDisconnect()
- func (ds *DataStore) Total(username string) int
- func (ds *DataStore) TotalErr(username string) (int, error)
- func (ds *DataStore) Unread(username string) int
- func (ds *DataStore) UnreadCount(username string) int
- type GreyHost
- type GreyMail
- type ListQuery
- type LoginForm
- type MIMEBody
- type MIMEPart
- type Message
- type Messages
- type MongoDB
- func (mongo *MongoDB) Close()
- func (mongo *MongoDB) DeleteAll() error
- func (mongo *MongoDB) DeleteOne(id string) error
- func (mongo *MongoDB) IsGreyHost(hostname string) (int, error)
- func (mongo *MongoDB) IsGreyMail(email, t string) (int, error)
- func (mongo *MongoDB) List(username, domain string, start int, limit int) (*Messages, error)
- func (mongo *MongoDB) Load(id string) (*Message, error)
- func (mongo *MongoDB) LoadAttachment(id string) (*Message, error)
- func (mongo *MongoDB) Login(username, password string) (*User, error)
- func (mongo *MongoDB) MessageByUID(username, domain string, uid uint32) (Message, error)
- func (mongo *MongoDB) MessageSetBySequenceNumber(username, domain string, set SequenceSet) Messages
- func (mongo *MongoDB) MessageSetByUID(username, domain string, set SequenceSet) Messages
- func (mongo *MongoDB) MessageSetFlags(username, domain, seq string)
- func (mongo *MongoDB) NextId(username string) int
- func (mongo *MongoDB) Pop3GetDele(username string, domain string, sequence int) error
- func (mongo *MongoDB) Pop3GetList(username string, domain string) (Messages, error)
- func (mongo *MongoDB) Pop3GetRetr(username string, domain string, sequence int) (Message, error)
- func (mongo *MongoDB) Pop3GetStat(username, domain string) (int, int, error)
- func (mongo *MongoDB) Pop3GetUidl(username string, domain string) (Messages, error)
- func (mongo *MongoDB) Recent(username, domain string) int
- func (mongo *MongoDB) RemoveRecent(m Message)
- func (mongo *MongoDB) Store(m *Message) (string, error)
- func (mongo *MongoDB) StoreGreyHost(h *GreyHost) (string, error)
- func (mongo *MongoDB) StoreGreyMail(m *GreyMail) (string, error)
- func (mongo *MongoDB) StoreSpamIp(s SpamIP) (string, error)
- func (mongo *MongoDB) Total(username, domain string) int
- func (mongo *MongoDB) TotalErr(username, domain string) (int, error)
- func (mongo *MongoDB) Unread(username, domain string) int
- func (mongo *MongoDB) UnreadCount(username, domain string) int
- type Path
- type SequenceNumber
- type SequenceRange
- type SequenceSet
- type Sequences
- type SpamIP
- type StatQuery
- type UidlQuery
- type User
Constants ¶
const InternalDate = "02-Jan-2006 15:04:05 +0700"
Date format used in INTERNALDATE fetch parameter
const RFC822Date = "Mon, 2 Jan 2006 15:04:05 +0700"
RFC822 date format used by IMAP in go date format
Variables ¶
This section is empty.
Functions ¶
func Encrypt_Password ¶
func FormatDate ¶
func MIMEHeaderToString ¶
func MIMEHeaderToString(header textproto.MIMEHeader) string
MIMEHeaderToString converts a textproto.MIMEHeader into its string representation.
func MimeHeaderDecode ¶
Decode strings in Mime header format eg. =?ISO-2022-JP?B?GyRCIVo9dztSOWJAOCVBJWMbKEI=?=
func SplitParams ¶
SplitParams splits parameters in IMAP arguments so that they're easily readable.
func Validate_Password ¶
func WriteMIMEHeader ¶
WriteMIMEHeader writes the MIME header out in the standard format. This should eventually be superseded by textproto.MIMEHeader.Write(w) once it is implemented in the go standard library.
Types ¶
type Attachment ¶
type Attachment struct {
Boundary string
Id string
Body string
FileName string
ContentType string
Charset string
MIMEVersion string
TransferEncoding string
Size int
}
func (*Attachment) SaveToFile ¶
func (at *Attachment) SaveToFile() error
type ComposeForm ¶
type ComposeForm struct {
To string
Cc string
Subject string
Message string
Errors map[string]string
}
func (*ComposeForm) Validate ¶
func (f *ComposeForm) Validate() bool
type Content ¶
type Content struct {
Headers map[string][]string
TextBody string
HtmlBody string
Size int
Body string
}
func ContentFromString ¶
type ContentQuery ¶
type ContentQuery struct {
Size int
}
type DataStore ¶
type DataStore struct {
Config config.DataStoreConfig
Domain string
Storage interface{}
SaveMailChan chan *config.SMTPMessage
NotifyMailChan chan interface{}
}
func (*DataStore) CheckGreyHost ¶
Check if host address is in greylist h -> hostname client ip
func (*DataStore) CheckGreyMail ¶
Check if email address is in greylist t -> type (from/to) m -> local mailbox d -> domain h -> client IP
func (*DataStore) MessageSetBySequenceNumber ¶
func (ds *DataStore) MessageSetBySequenceNumber(username string, set SequenceSet) Messages
func (*DataStore) MessageSetByUID ¶
func (ds *DataStore) MessageSetByUID(username string, set SequenceSet) Messages
func (*DataStore) MessageSetFlags ¶
func (*DataStore) Pop3GetDele ¶
func (*DataStore) Pop3GetRetr ¶
func (*DataStore) RemoveRecent ¶
func (*DataStore) SaveSpamIP ¶
func (*DataStore) StorageConnect ¶
func (ds *DataStore) StorageConnect()
func (*DataStore) StorageDisconnect ¶
func (ds *DataStore) StorageDisconnect()
func (*DataStore) UnreadCount ¶
type ListQuery ¶
type ListQuery struct {
Id string
Sequence int
Content ContentQuery
}
type Message ¶
type Message struct {
Id string
Sequence int
Subject string
From *Path
To []*Path
Created time.Time
Attachments []*Attachment
Ip string
Content *Content
MIME *MIMEBody
Starred bool
Unread bool
Recent bool
Deleted bool
}
func ParseSMTPMessage ¶
func ParseSMTPMessage(mongo *MongoDB, m *config.SMTPMessage, hostname string, mimeParser bool) *Message
TODO support nested MIME content
type MongoDB ¶
type MongoDB struct {
Config config.DataStoreConfig
Session *mgo.Session
Messages *mgo.Collection
Users *mgo.Collection
Hosts *mgo.Collection
Emails *mgo.Collection
Mailboxes *mgo.Collection
Spamdb *mgo.Collection
Sequences *mgo.Collection
}
func CreateMongoDB ¶
func CreateMongoDB(c config.DataStoreConfig) *MongoDB
func (*MongoDB) MessageByUID ¶
func (*MongoDB) MessageSetBySequenceNumber ¶
func (mongo *MongoDB) MessageSetBySequenceNumber(username, domain string, set SequenceSet) Messages
func (*MongoDB) MessageSetByUID ¶
func (mongo *MongoDB) MessageSetByUID(username, domain string, set SequenceSet) Messages
func (*MongoDB) MessageSetFlags ¶
func (*MongoDB) Pop3GetDele ¶
func (*MongoDB) Pop3GetList ¶
func (*MongoDB) Pop3GetRetr ¶
func (*MongoDB) Pop3GetStat ¶
func (*MongoDB) Pop3GetUidl ¶
func (*MongoDB) RemoveRecent ¶
func (*MongoDB) UnreadCount ¶
type Path ¶
func PathFromString ¶
type SequenceNumber ¶
type SequenceNumber string
SequenceNumber represents a single message identifier. Could be UID or sequence number. See RFC3501 section 9.
func (SequenceNumber) IsValue ¶
func (s SequenceNumber) IsValue() bool
IsValue returns true if the sequence number is a numeral value and not nil or *.
func (SequenceNumber) Last ¶
func (s SequenceNumber) Last() bool
Last returns true if this sequence number indicates the *last* sequence number or UID available in this mailbox. If false, this sequence number contains an integer value.
func (SequenceNumber) Nil ¶
func (s SequenceNumber) Nil() bool
Nil returns true if no sequence number was specified.
func (SequenceNumber) Value ¶
func (s SequenceNumber) Value() (uint32, error)
Value returns the integer value of the sequence number, if any is set. If Nil or Last is true (ie, this sequence number is not an integer value) then this returns 0 and an error.
type SequenceRange ¶
type SequenceRange struct {
Min SequenceNumber
Max SequenceNumber
}
SequenceRange represents a range of identifiers. eg in IMAP: 5:9 or 15:*
func InterpretMessageRange ¶
func InterpretMessageRange(imapMessageRange string) (seqRange SequenceRange, err error)
InterpretMessageRange creates a SequenceRange from the given string in the IMAP format.
type SequenceSet ¶
type SequenceSet []SequenceRange
SequenceSet represents set of sequence ranges. eg in IMAP: 1,3,5:9,18:*
func InterpretSequenceSet ¶
func InterpretSequenceSet(imapSequenceSet string) (seqSet SequenceSet, err error)
InterpretSequenceSet creates a SequenceSet from the given string in the IMAP format.
type User ¶
type User struct {
Id bson.ObjectId `bson:"_id"`
Firstname string
Lastname string
Email string
Username string
Password string
Avatar string
Website string
Location string
Tagline string
Bio string
JoinedAt time.Time
IsSuperuser bool
IsActive bool
ValidateCode string
ResetCode string
LastLoginTime time.Time
LastLoginIp string
LoginCount int64
}
func (*User) SetPassword ¶
SetPassword takes a plaintext password and hashes it with bcrypt and sets the password field to the hash.