evmail

package module
v0.0.0-...-7113a22 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2013 License: BSD-2-Clause-Views Imports: 17 Imported by: 0

README

evmail

imap and smtp email management package

Licence: FreeBSD

donation

Flattr this git repo

documentation

package documentation at go.pkgdoc.org

git commit hooks

enable commit hooks via

    cd .git ; rm -rf hooks; ln -s ../git-hooks hooks ; cd ..

continous integration

Build Status

usage send

sending simple mail

Mail := NewEVMailEmail()
Mail.User = "<sender@address.com>"
Mail.Password = "<secret_password>"
Mail.Server = "smtp.address.com"
Mail.Port = 587
Mail.To = []string{"<receipient@address.com>"}
Mail.From = "<sender@address.com>"
Mail.Subject = "Hello from EVMail!"
Mail.Body = "EVMail content here ..."
err := Mail.Send()
if err != nil {
	log.Fatal(err)
}

sending mail with attachment

Mail := NewEVMailEmail()
Mail.User = "<sender@address.com>"
Mail.Password = "<secret_password>"
Mail.Server = "smtp.address.com"
Mail.Port = 587
Mail.To = []string{"<receipient@address.com>"}
Mail.From = "<sender@address.com>"
Mail.Subject = "Hello from EVMail!"
Mail.Body = "EVMail content here ..."
Mail.Attach("/path/to/your/file")
err := Mail.Send()
if err != nil {
	log.Fatal(err)
}

usage get message from imap

conn, serverResponse, err := EVMailImapConnect("imap.adress.com", 993, "certs/client.pem", "certs/client.key")
log.Println(err, serverResponse, conn)
loginResponse := EVMailImapLogin(conn, "<user@address.com>", "<secret_password>")
log.Println(loginResponse)
inboxInfo := EVMailImapGetMailBoxInformation(conn, "/INBOX")
log.Println(inboxInfo)
inboxHeader, err := EVMailImapGetAllMailBoxMessageHeader(conn, inboxInfo)
log.Println(err, inboxHeader)
for _, mailHeader := range inboxHeader.Headers {
	email := EVMailImapGetMessageById(conn, "INBOX", mailHeader.Id)
	log.Println("from:", email.Body.From, "subject:", email.Body.Subject)
	log.Println(email.Body.Body)
}
logoutResponse := EVMailImapLogout(conn)
log.Println(logoutResponse)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version string = "v1"

Functions

func CheckRegExpString

func CheckRegExpString(Expression string, String string) string

func ImapConnect

func ImapConnect(Server string, Port int, Pem string, Key string) (*tls.Conn, string, error)

func ImapGetAllMailboxes

func ImapGetAllMailboxes(conn *tls.Conn, Path string) []string

func ImapGetRawMailBoxMessageHeader

func ImapGetRawMailBoxMessageHeader(conn *tls.Conn, MailId int) string

func ImapLogin

func ImapLogin(conn *tls.Conn, UserName string, Password string) string

func ImapLogout

func ImapLogout(conn *tls.Conn) string

func ImapParseMailHeader

func ImapParseMailHeader(MessageHeaderRaw string, Header string) string

func ImapReadMailBoxMessagesHeader

func ImapReadMailBoxMessagesHeader(conn *tls.Conn) (string, error)

func ImapReadServerMessage

func ImapReadServerMessage(conn *tls.Conn) (string, int)

func ImapSendServerMessage

func ImapSendServerMessage(conn *tls.Conn, message string) (string, error)

func LoadMsgErrors

func LoadMsgErrors(msg *evmessage.Message) *evmessage.Message

func SuperPlainAuth

func SuperPlainAuth(UserName string, Password string) smtp.Auth

Types

type Email

type Email struct {
	Server      string   `xml:"Server"`
	Port        int      `xml:"Port"`
	User        string   `xml:"User"`
	Password    string   `xml:"Password"`
	From        string   `xml:"From"`
	To          []string `xml:"To>Recipient"`
	Subject     string   `xml:"Subject"`
	Body        string   `xml:"Text"`
	Html        string   `xml:"Html"`
	Raw         string   `xml:"Raw"`
	Attachments map[string][]byte
}

func ImapEmailSplitBoundary

func ImapEmailSplitBoundary(EmailString string, conn *tls.Conn, MailId int) *Email

func ImapReadEmailMessage

func ImapReadEmailMessage(conn *tls.Conn, MailId int) (*Email, error)

func NewEmail

func NewEmail() *Email

func (*Email) Attach

func (Mail *Email) Attach(file string) error

func (*Email) EVName

func (mail *Email) EVName() string

func (*Email) RpcSend

func (mail *Email) RpcSend(requestMsg *evmessage.Message, responseMsg *evmessage.Message) (e error)

func (*Email) Send

func (Mail *Email) Send() error

type HttpRpcProxy

type HttpRpcProxy struct{}

func NewHttpRpcProxy

func NewHttpRpcProxy() *HttpRpcProxy

func (*HttpRpcProxy) HttpCreateRequest

func (rpcP *HttpRpcProxy) HttpCreateRequest(vars map[string]string, r *evmessage.Request) (*evmessage.Request, error)

type ImapEmail

type ImapEmail struct {
	Id   int    `xml:"Id"`
	Body *Email `xml:"Body"`
}

func ImapGetMessageById

func ImapGetMessageById(conn *tls.Conn, MailBoxPath string, MailId int) *ImapEmail

func NewImapEmail

func NewImapEmail() *ImapEmail

type ImapEmailHeader

type ImapEmailHeader struct {
	Id                    int    `xml:"Id"`
	DeliverdTo            string `xml:"DeliverdTo"`
	Received              string `xml:"Received"`
	ReturnPath            string `xml:"ReturnPath"`
	ReceivedSPF           string `xml:"Received-SPF"`
	AuthenticationResults string `xml:"Authentication-Results"`
	MimeVersion           string `xml:"Mime-Version"`
	Date                  string `xml:"Date"`
	MessageID             string `xml:"Message-ID"`
	Subject               string `xml:"Subject"`
	From                  string `xml:"From"`
	To                    string `xml:"To"`
	ContentType           string `xml:"Content-Type"`
	XGmMessageState       string `xml:"X-Gm-Message-State"`
}

func ImapGetMailBoxMessageHeader

func ImapGetMailBoxMessageHeader(conn *tls.Conn, MailId int) *ImapEmailHeader

func NewImapEmailHeader

func NewImapEmailHeader() *ImapEmailHeader

type ImapMailBoxAllMessages

type ImapMailBoxAllMessages struct {
	Headers []ImapEmailHeader `xml:"Headers>Header"`
}

func ImapGetAllMailBoxMessageHeader

func ImapGetAllMailBoxMessageHeader(conn *tls.Conn, MailBox *ImapMailBoxInformation) (*ImapMailBoxAllMessages, error)

func NewImapMailBoxAllMessages

func NewImapMailBoxAllMessages() *ImapMailBoxAllMessages

type ImapMailBoxInformation

type ImapMailBoxInformation struct {
	Flags       []string `xml:"Flags>Flag"`
	Mails       int      `xml:"Mails"`
	Recent      int      `xml:"Recent"`
	NonExistent bool     `xml:"NonExistent"`
	Path        string   `xml:"Path"`
}

func ImapGetMailBoxInformation

func ImapGetMailBoxInformation(conn *tls.Conn, Path string) *ImapMailBoxInformation

func NewImapMailBoxInformation

func NewImapMailBoxInformation() *ImapMailBoxInformation

type ImapMailBoxes

type ImapMailBoxes struct {
	MailBoxes []ImapMailBoxInformation `xml:"Mailboxes>Mailbox"`
}

func ImapGetMailBoxesInformation

func ImapGetMailBoxesInformation(conn *tls.Conn) *ImapMailBoxes

func NewImapMailBoxes

func NewImapMailBoxes() *ImapMailBoxes

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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