cmd

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Example
package main

import (
	"log"
	"os"
	"strings"

	"github.com/jhillyerd/enmime"
	"github.com/jhillyerd/enmime/cmd"
)

func main() {
	mail := `From: James Hillyerd <james@inbucket.org>
To: Greg Reader <greg@inbucket.org>, Root Node <root@inbucket.org>
Date: Sat, 04 Dec 2016 18:38:25 -0800
Subject: Example Message
Content-Type: multipart/mixed; boundary="Enmime-Test-100"

--Enmime-Test-100
Content-Type: text/plain

Text section.
--Enmime-Test-100
Content-Type: text/html

<em>HTML</em> section.
--Enmime-Test-100--
`
	// Convert MIME text to Envelope
	r := strings.NewReader(mail)
	env, err := enmime.ReadEnvelope(r)
	if err != nil {
		log.Fatal(err)
		return
	}

	err = cmd.EnvelopeToMarkdown(os.Stdout, env, "Example Message Output")
	if err != nil {
		log.Fatal(err)
		return
	}

}
Output:

Example Message Output
======================

## Header
    Content-Type: multipart/mixed; boundary="Enmime-Test-100"
    Date: Sat, 04 Dec 2016 18:38:25 -0800

## Envelope
### From
- James Hillyerd `<james@inbucket.org>`

### To
- Greg Reader `<greg@inbucket.org>`
- Root Node `<root@inbucket.org>`

### Subject
Example Message

## Body Text
Text section.

## Body HTML
<em>HTML</em> section.

## Attachment List

## MIME Part Tree
    multipart/mixed
    |-- text/plain
    `-- text/html

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnvelopeToMarkdown

func EnvelopeToMarkdown(w io.Writer, e *enmime.Envelope, name string) error

EnvelopeToMarkdown renders the contents of an enmime.Envelope in Markdown format. Used by mime-dump and mime-extractor commands.

func FormatPart

func FormatPart(w io.Writer, p *enmime.Part, indent string)

FormatPart pretty prints the Part tree

Types

This section is empty.

Directories

Path Synopsis
Package main outputs a markdown formatted document describing the provided email
Package main outputs a markdown formatted document describing the provided email
Package main extracts attachments from the provided email
Package main extracts attachments from the provided email

Jump to

Keyboard shortcuts

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