Skip to content

A simple wrapper to extend net/mail.Message

License

Notifications You must be signed in to change notification settings

codykaup/go-mail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-mail

GoDoc

go-mail creates a simple wrapper around [net/mail.Message] to extend common functionality.

Installing

$ go get -u github.com/codykaup/go-mail

Example

Reading a message

import (
	"bufio"
	"fmt"
	"os"

	mail "github.com/codykaup/go-mail"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	message, _ := mail.ReadMessage(reader)

	fmt.Printf("Headers: %+v\n", message.Header)
	fmt.Printf("Body: %+v\n", message.Body)
}

Append a header

import (
	"bufio"
	"fmt"
	"os"

	mail "github.com/codykaup/go-mail"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	message, _ := mail.ReadMessage(reader)

	fmt.Printf("Headers: %+v\n", message.Header)

	entry, _ := mail.NewHeaderEntry("Cc", "[email protected]")
	message.AppendHeader(entry)

	fmt.Printf("New Headers: %+v\n", message.Header)
}

Get the full message

import (
	"bufio"
	"fmt"
	"os"

	mail "github.com/codykaup/go-mail"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	message, _ := mail.ReadMessage(reader)

	fmt.Println(message.Join())
}

About

A simple wrapper to extend net/mail.Message

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages