email

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Copyright 2022 Hal Canary Use of this program is governed by the file LICENSE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendFile

func SendFile(dst Address, path, contentType string, secrets EmailSecrets) error

Send a file to a single destination.

Types

type Address added in v0.4.1

type Address = mail.Address

type Attachment

type Attachment struct {
	Filename    string // Optional
	ContentType string // If empty, determined via http.DetectContentType
	Data        []byte
	Textual     bool // If true and Data is valid UTF-8, then encode as quoted-printable over base64
}

Attachment for an email.

type Email

type Email struct {
	Date        time.Time // If not set, use time.Now()
	To          []Address
	Cc          []Address
	Bcc         []Address
	From        Address
	Subject     string
	Content     string // Assumed to be text/plain.
	Attachments []Attachment
	Headers     map[string]string // Optional extra headers.
}

An electric mail message.

func (Email) Make

func (mail Email) Make(out io.Writer)

Make, but do not send an email message.

func (Email) Send

func (m Email) Send(secrets EmailSecrets) error

Send the given email using the provided SMTP secrets.

type EmailSecrets

type EmailSecrets struct {
	SmtpHost string            // example: "smtp.gmail.com"
	SmtpUser string            // example: "halcanary@gmail.com"
	SmtpPass string            // for gmail, is a App Password
	From     Address           // example: "Hal Canary <halcanary@gmail.com>"
	Headers  map[string]string // extra headers to be added to email.
}

Data structure representing instructions for connecting to SMTP server. Headers are additional headers to be added to outgoing email.

func GetSecrets

func GetSecrets(path string) (EmailSecrets, error)

Read email secrets from the given file.

Jump to

Keyboard shortcuts

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