Skip to content

davidbanham/marcel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Marcel

PkgGoDev

Marcel is a tool to generate IETF compliant emails in raw MIME format. I mainly use this for generating emails with attachments and sending them via amazon SES. If that's what you're doing too, you may want notifications

Marcel supports:

  • HTML bodies
  • Text bodies
  • Emails with only an HTML or Text body
  • Attachments
  • JSON serialisation of emails and attachments

Marcel does not support:

  • Inline attachments

Marcel endeavours to pass the IETF Msglint tool with no errors. If you have a payload that generates errors please file an issue.

Example

package main

import (
	"fmt"
	"log"
	"strings"

	"github.com/davidbanham/marcel"
)

func main() {
	mail := marcel.Email{
		To:      "[email protected]",
		From:    "[email protected]",
		ReplyTo: "[email protected]", // optional
		Text:    "This is the important information in text format",
		HTML:    "This is the important information in <b>HTML</b> format",
		Subject: "A really important email",
		Attachments: []marcel.Attachment{
			marcel.Attachment{
				ContentType: "text/plain",
				Data:        strings.NewReader("A very important attachment"), // Data will be base64 encoded before sending
				Filename:    "test_data.txt",
			},
		},
	}

	rawEmail, err := mail.ToMIME()
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(string(rawEmail))
}