Categorygithub.com/FetchWeb/Email
repositorypackage
0.2.3
Repository: https://github.com/fetchweb/email.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

FetchWeb Mail

License: MIT Go Report Card Go Doc GitHub release

Introduction

FetchWeb Email is a simple SMTP Email API written in Go with no dependencies outside of the Go standard library.

Setup Example

package main

import (
	"encoding/json"
	"io/ioutil"

	email "github.com/FetchWeb/Email"
)

func main() {
	// Initailise credentials & data objects.
	creds := &email.Credentials{
		Address: "<Sending email address>",
		Hostname: "<Hostname of SMTP Server>",
		Name: "<Name appearing on email>",
		Port: "<Port email being sent on>",
		Password "<Password to email account>"
	}
	data := &email.Data{
		Attachments: make(map[string]*email.Attachment)
	}

	// Add email body.
	data.Body = "Hello world from FetchWeb Mail!"

	// Add attachment from file.
	if err := data.AddAttachmentFromFile("<Attachment directory>", false); err != nil {
		panic(err)
	}

	// Send email.
	if err := email.Send(creds, data); err != nil {
		panic(err)
	}
}