ews

package module
v0.0.0-...-916e202 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2017 License: MIT Imports: 5 Imported by: 0

README

very dumb, hacky, possibly flaky package to send emails from an Exchange server via EWS (in the event yours doesn't expose a SMTP server)

usage:

	b, err := ews.BuildTextEmail(
		"me@server.com",
		[]string{"friend@example.com", "someone@else.com"},
		"An email subject",
		[]byte("The email body, as plain text"))
	if err != nil {
		// handle err
	}
	resp, err := ews.Issue(
		"https://exhange.server.com/ews/Exchange.asmx",
		"domain\\username",
		"password",
		b)
	if err != nil {
		// handle err
	}
	if resp.StatusCode != 200 {
		// read body and figure out what happened
	}
	// read or ignore body; the email was sent

the other exported types are just the raw data structures for the request XML; you can ignore them

I'm not sure if I'll develop this further; feel free to (warning: here be SOAP)
some resources I used are in comments in the code

TODOs
- figure out why UTF-8 isn't used for email bodies, or how to force the encoding

Documentation

Overview

26 august 2016

26 august 2016

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTextEmail

func BuildTextEmail(from string, to []string, subject string, body []byte) ([]byte, error)

func Issue

func Issue(ewsAddr string, username string, password string, body []byte) (*http.Response, error)

Types

type Body

type Body struct {
	BodyType string `xml:"BodyType,attr"`
	Body     []byte `xml:",chardata"`
}

type CreateItem

type CreateItem struct {
	XMLName            struct{}          `xml:"m:CreateItem"`
	MessageDisposition string            `xml:"MessageDisposition,attr"`
	SavedItemFolderId  SavedItemFolderId `xml:"m:SavedItemFolderId"`
	Items              Messages          `xml:"m:Items"`
}

type DistinguishedFolderId

type DistinguishedFolderId struct {
	Id string `xml:"Id,attr"`
}

type Mailbox

type Mailbox struct {
	EmailAddress string `xml:"t:EmailAddress"`
}

type Message

type Message struct {
	ItemClass    string     `xml:"t:ItemClass"`
	Subject      string     `xml:"t:Subject"`
	Body         Body       `xml:"t:Body"`
	Sender       OneMailbox `xml:"t:Sender"`
	ToRecipients XMailbox   `xml:"t:ToRecipients"`
}

type Messages

type Messages struct {
	Message []Message `xml:"t:Message"`
}

type OneMailbox

type OneMailbox struct {
	Mailbox Mailbox `xml:"t:Mailbox"`
}

type SavedItemFolderId

type SavedItemFolderId struct {
	DistinguishedFolderId DistinguishedFolderId `xml:"t:DistinguishedFolderId"`
}

type XMailbox

type XMailbox struct {
	Mailbox []Mailbox `xml:"t:Mailbox"`
}

Jump to

Keyboard shortcuts

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