mail

package
v0.0.0-...-d62ea78 Latest Latest
Warning

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

Go to latest
Published: May 2, 2018 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EncodingMultipartWriter

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

EncodingMultipartWriter contains headers and information needed to write a MIME Multipart message

func NewEncodingMultipartWriter

func NewEncodingMultipartWriter(w io.Writer, multitype, protocol string, extraHeaders map[string]string) *EncodingMultipartWriter

NewEncodingMultipartWriter returns a new encoding multipart writer of the given type writing to w. The multitype can be for example "mixed", "alternative", or "encrypted". Optionally, a protocol for the Content-Type header can be given, for example "application/pgp-encrypted" The writer defines the headers "Mime-Version", "Content-Type" and "Content-Transfer-Encoding". Additional headers can be passed via the extraHeaders field. The extraHeaders field takes precedence.

func (*EncodingMultipartWriter) Close

func (w *EncodingMultipartWriter) Close() error

Close writes the trailing information for an multipartWriter

func (*EncodingMultipartWriter) WriteAttachedFile

func (w *EncodingMultipartWriter) WriteAttachedFile(name, mimeType, description string) (io.Writer, error)

WriteAttachedFile writes a multipart header for an attached file and provides a writer for the file contents

func (*EncodingMultipartWriter) WriteInlineFile

func (w *EncodingMultipartWriter) WriteInlineFile(name, mimeType, description string) (io.Writer, error)

WriteInlineFile writes a multipart header for an inline file and provides a writer for the file contents

func (*EncodingMultipartWriter) WritePGPMIMEVersion

func (w *EncodingMultipartWriter) WritePGPMIMEVersion() error

WritePGPMIMEVersion writes a multipart containing PGP Version information

func (*EncodingMultipartWriter) WritePlainText

func (w *EncodingMultipartWriter) WritePlainText(text string) (err error)

WritePlainText writes the given text as a text/plain segment

type GpgUtility

type GpgUtility interface {
	CheckMessageSignature(message io.Reader, signature io.Reader, checkedSignerKey gpg.Key) error
	ReadKey(r io.Reader) (gpg.Key, error)
	EncryptMessage(output io.Writer, recipient gpg.Key) (plaintext io.WriteCloser, err error)
	DecryptMessage(message io.Reader) (result io.Reader, err error)
	DecryptSignedMessage(message io.Reader, output io.Writer, signerKey gpg.Key) error
	ServerIdentity() string
}

GpgUtility is required required to manage signatures and mail encryption

type MessageEncrypter

type MessageEncrypter interface {
	EncryptMessage(output io.Writer, recipientKey gpg.Key) (plaintext io.WriteCloser, err error)
	ServerIdentity() string
}

MessageEncrypter is a struct able to sign a message and encrypt it for the recipient key

type MimeEntity

type MimeEntity struct {
	Header       textproto.MIMEHeader
	Content      []byte
	Parts        []MimeEntity
	IsAttachment bool
	SignedBy     gpg.Key
}

MimeEntity describes a multipart MIME encoded message

func (*MimeEntity) FindAttachment

func (entity *MimeEntity) FindAttachment(mimeType string) ([]byte, error)

FindAttachment returns the first attachment of the given mimeType or an error if none is found.

func (*MimeEntity) GetSender

func (entity *MimeEntity) GetSender() string

GetSender returns the value of the "From" header.

func (*MimeEntity) GetSubject

func (entity *MimeEntity) GetSubject() string

GetSubject returns the value of the "Subject" header.

type MimeMediaType

type MimeMediaType struct {
	Value  string
	Params map[string]string
}

MimeMediaType describes a Media Type with associated parameters

type OutgoingMail

type OutgoingMail struct {
	Message        string
	RecipientEmail string
	RecipientKey   gpg.Key
	Attachment     []byte
	GPG            MessageEncrypter
}

OutgoingMail describes the contents of the mail to be sent

func (OutgoingMail) Bytes

func (m OutgoingMail) Bytes() ([]byte, error)

Bytes returns the given message as an OpenPGP/MIME encrypted and signed message (RFC 2440 and 3156)

func (OutgoingMail) From

func (m OutgoingMail) From() string

From returns the sender of the mail.

type Parser

type Parser struct {
	Gpg GpgUtility
}

Parser parses MIME mails.

func (*Parser) ParseMail

func (parser *Parser) ParseMail(mailReader io.Reader) (*MimeEntity, error)

ParseMail returns a MimeEntity containing the parsed form of the input email

Jump to

Keyboard shortcuts

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