Simap

package
v0.0.0-...-78f21bf Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2014 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package Simap implements a simple Imap client which --Fetches,Copies,Moves emails from mailboxes. --Creates,Deletes Mboxes/Folders on the Server. --Marks,Unmarks Imap Flags from the mails. --Can Skip Certificate Verification of the IMAP Server. (Good for IMAP servers using SelfSigned Cerificates.)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BodyOfType

func BodyOfType(msg *mail.Message, mimetype string) (body io.Reader, err error)

func CopyEmails

func CopyEmails(acct *IMAPAccount, src string, dst string, uids []uint32, jobSize int, skipCerti bool) (err error)

CopyEmails copies Emails having unique identifiers uids (NOT sequence numbers) of mailbox src to mailbox dst by making bunches of jobsize. If dst mbox doesnt exist then it will create it. IF skipCerti is true then it will not check for the validity of the Certificate of the IMAP server, good only if IMAP server is using self signed certi. e.g. if jobsize =10 and total emails =100 then it will create 10 bunches of size 10 and then copy them.

func CreateMbox

func CreateMbox(acct *IMAPAccount, name string, skipCerti bool) (err error)

CreateMbox creates a mailbox/folder on the server If already exists then do nothing IF skipCerti is true then it will not check for the validity of the Certificate of the IMAP server, good only if IMAP server is using self signed certi.

func DeleteEmails

func DeleteEmails(acct *IMAPAccount, src string, uids []uint32, jobSize int, skipCerti bool) (err error)

DeleteEMails deletes mails having uids from src.Arguments have same meaning as CopyEmails

func DeleteMbox

func DeleteMbox(acct *IMAPAccount, name string, skipCerti bool) (err error)

DeleteMbox deletes a mailbox/folder on the server If does not exist then do nothing

func Dial

func Dial(server *IMAPServer, skipCerti bool) (c *imap.Client, err error)

Dial dials a connection to the IMAP server If skipCerti is true then it will not check for the validity of the Certificate of the IMAP server, good only if IMAP server is using self signed certi.

func FetchAllUIDs

func FetchAllUIDs(c *imap.Client) (uids []uint32, err error)

func GetMessageAsJSON

func GetMessageAsJSON(msg MsgData) (msgJSON string, err error)

func GpgBody

func GpgBody(msg *mail.Message) (body string, err error)

func HTMLBody

func HTMLBody(msg *mail.Message) (body string, err error)

func MarkEmails

func MarkEmails(acct *IMAPAccount, src string, imapFlag string, uids []uint32, jobSize int, skipCerti bool) (err error)

MarkEmails marks mails having uids from src with IMAP flag specified in imapFlag. See RFC 3501 section 2.3.2 for a list of all valid flags.

func MoveEmails

func MoveEmails(acct *IMAPAccount, src string, dst string, uids []uint32, jobSize int, skipCerti bool) (err error)

MoveEmails is similar to CopyEmails but it moves the mails to dst hence deleting mails from src.

func MultipartBodyOfType

func MultipartBodyOfType(msg *mail.Message, mimetype string) (body io.Reader, err error)

func SearchUIDs

func SearchUIDs(c *imap.Client, query string) (uids []uint32, err error)

func TextBody

func TextBody(msg *mail.Message) (body string, err error)

func UnMarkEmails

func UnMarkEmails(acct *IMAPAccount, src string, imapFlag string, uids []uint32, jobSize int, skipCerti bool) (err error)

UnmarkEmails unmarks/resets flags of mails having uids from src with IMAP flag specified in imapFlag. See RFC 3501 section 2.3.2 for a list of all valid flags.

func WaitResp

func WaitResp(cmd *imap.Command, err error) error

Types

type IMAPAccount

type IMAPAccount struct {
	Username string
	Password string
	Server   *IMAPServer
}

type IMAPServer

type IMAPServer struct {
	Host string
	Port uint16
}

type MsgData

type MsgData struct {
	Imap_uid uint32
	From     string
	To       string
	Subject  string
	Body     string
	HtmlBody string
	GpgBody  string
	Header   mail.Header
}

func FetchMessages

func FetchMessages(c *imap.Client, uidSet *imap.SeqSet) (fetched []MsgData, err error)

func GetEMails

func GetEMails(acct *IMAPAccount, query string, mbox string, jobSize int, skipCerti bool) (mails []MsgData, err error)

GetEmails gets Emails from mailbox mbox in Struct of Type MsgData. It searches the mailbox for messages that match the given searching criteria mentioned in query string. See RFC 3501 section 6.4.4 for a list of all valid search keys. It is the caller's responsibility to quote strings when necessary. All strings must use UTF-8 encoding.

func GetMessage

func GetMessage(msg *mail.Message, uid uint32) (msgData MsgData)

type UIDFetchJob

type UIDFetchJob struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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