mbox

package module
v0.0.0-...-d168b46 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2017 License: MIT Imports: 14 Imported by: 0

README

mbox library

save an email to an mbox file
package main

import "github.com/aerth/mbox"

func main(){
mbox.Destination = "me@localhost"

// Choose file name
mbox.Open("my.mbox")

// Build the email
var form mbox.Form
form.Email = "root@localhost"
form.Subject = "As seen on TV!!!"
form.Message = "This really works!"

// Save message to mailbox
mbox.Save(&form)
}


Documentation

Overview

Package mbox saves a form to a local .mbox file (opengpg option)

Usage of mbox library is as follows:

Define mbox.Destination variable in your program

Accept an email, populate the mbox.Form struct like this:

mbox.From = "joe"
mbox.Email = "joe@blowtorches.info
mbox.Message = "hello world"
mbox.Subject = "re: hello joe"
mbox.Save()

Package mbox saves a form to a local .mbox file (opengpg option)

Usage of mbox library is as follows:

Define mbox.Destination variable in your program

Accept an email, populate the mbox.Form struct like this:

mbox.From = "joe"
mbox.Email = "joe@blowtorches.info
mbox.Message = "hello world"
mbox.Subject = "re: hello joe"
mbox.Save()

Index

Constants

This section is empty.

Variables

View Source
var (
	// ValidationLevel should be set to something other than 1 to resolve hostnames and validate emails
	ValidationLevel = 1
	// Destination is the address where mail is "sent", its useful to change this to the address you will be replying to.
	Destination = "mbox@localhost"

	// Mail is the local mbox, implemented as a logger
	Mail *os.File
)
View Source
var Writer = make(chan *Form)

Functions

func Open

func Open(file string) (err error)

Open mbox file, rw+create+append mode ( step 1 )

func PGPEncode

func PGPEncode(plain string, publicKey []byte) (encStr string, err error)

PGPEncode handles the actual encrypting of the message. Outputs ascii armored gpg message or an error.

func Save

func Save(form *Form) error

Save sends an entire email to the writer

Types

type Form

type Form struct {
	From, Subject, Message string
	Sent, Received         time.Time
	Body                   []byte
}

Form is a single email. No Attachments yet.

func ParseFormGPG

func ParseFormGPG(destination string, query url.Values, publicKey []byte) (form *Form)

ParseFormGPG parses a url submitted query and returns a mbox.Form

func ParseQuery

func ParseQuery(query url.Values) *Form

ParseQuery returns a mbox.Form from url.Values

func ParseQueryGPG

func ParseQueryGPG(query url.Values, publicKey []byte) *Form

ParseQueryGPG returns a mbox.Form from a url.Values but encodes the form.Message if publicKey is not nil

func (*Form) Normalize

func (form *Form) Normalize() error

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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