Skip to content

Latest commit

 

History

History
59 lines (48 loc) · 1.24 KB

README.md

File metadata and controls

59 lines (48 loc) · 1.24 KB

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 / [email protected]