Categorygithub.com/scorredoira/email
modulepackage
0.0.0-20191107070024-dc7b732c55da
Repository: https://github.com/scorredoira/email.git
Documentation: pkg.go.dev

# README

PROJECT DISCONTINUED

This repository only exists for archival purposes.


email Travis-CI GoDoc Report card

An easy way to send emails with attachments in Go

Install

go get github.com/scorredoira/email

Usage

package email_test

import (
	"log"
	"net/mail"
	"net/smtp"

	"github.com/scorredoira/email"
)

func Example() {
	// compose the message
	m := email.NewMessage("Hi", "this is the body")
	m.From = mail.Address{Name: "From", Address: "[email protected]"}
	m.To = []string{"[email protected]"}

	// add attachments
	if err := m.Attach("email.go"); err != nil {
		log.Fatal(err)
	}

	// add headers
	m.AddHeader("X-CUSTOMER-id", "xxxxx")

	// send it
	auth := smtp.PlainAuth("", "[email protected]", "pwd", "smtp.zoho.com")
	if err := email.Send("smtp.zoho.com:587", auth, m); err != nil {
		log.Fatal(err)
	}
}

Html

	// use the html constructor
	m := email.NewHTMLMessage("Hi", "this is the body")

Inline

	// use Inline to display the attachment inline.
	if err := m.Inline("main.go"); err != nil {
		log.Fatal(err)
	}

# Functions

NewHTMLMessage returns a new Message that can compose an HTML email with attachments.
NewMessage returns a new Message that can compose an email with attachments.
Send sends the message.

# Structs

Attachment represents an email attachment.
Header represents an additional email header.
Message represents a smtp message.