mboxparser

package module
v0.0.0-...-32dea78 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2017 License: MIT Imports: 14 Imported by: 0

README

mboxparser

Build Status Coverage Status

mbox file parser for golang.

Usage

package main

import (
	"fmt"
	"github.com/zeny-io/mboxparser"
	"io"
	"os"
)

func main() {
	for n, arg := range os.Args {
		if n == 0 {
			continue
		}

		if mbox, err := mboxparser.ReadFile(arg); err == nil {
			for _, mail := range mbox.Messages {
				for k, vs := range mail.Header {
					for _, v := range vs {
						fmt.Printf("%s: %s\n", k, v)
					}
				}
				for _, body := range mail.Bodies {
					fmt.Println("====================================================")
					for k, vs := range body.Header {
						for _, v := range vs {
							fmt.Printf("%s: %s\n", k, v)
						}
					}
					fmt.Println("")
					io.Copy(os.Stdout, body.Content)
					fmt.Println("")
				}
				fmt.Println("====================================================\n\n")
			}
		} else {
			fmt.Printf("%s\n", err.Error())
		}
	}
}

License

MIT

Author

@rosylilly: Sho Kusano / sho-kusano@zeny.io

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body struct {
	Header   Header
	FileName string
	Content  io.Reader
}
type Header map[string][]string

func (Header) Del

func (h Header) Del(key string)

func (Header) Get

func (h Header) Get(key string) string

func (Header) Set

func (h Header) Set(key, val string)

type Mbox

type Mbox struct {
	Messages []*Message
}

func Read

func Read(r io.Reader) (*Mbox, error)

func ReadFile

func ReadFile(filename string) (*Mbox, error)

type Message

type Message struct {
	Header Header
	Bodies []*Body
}

func Decode

func Decode(msg *mail.Message) *Message

Jump to

Keyboard shortcuts

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