email

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Copyright (c) 2021 Kross IAM Project. https://github.com/krossdev/iam-ms/blob/main/LICENSE

Index

Constants

View Source
const (
	TVerifyEmail     = "verify-email"
	TAccountAddEmail = "account-add-email"
)

template name constants

Variables

This section is empty.

Functions

func ExecTemplate

func ExecTemplate(name string, locale string, data interface{}) (string, error)

load template from file, support i18n

func Setup

func Setup(conf *config.Mail)

propagation configuration from config file

func TemplateImagePath

func TemplateImagePath(name string) string

return full image path in template directory

func TemplateLogoPath

func TemplateLogoPath() string

return full logo path in template directory

Types

type Attachment

type Attachment struct {
	Filename  string // filename
	Data      []byte // attachment data
	Inline    bool   // is inline
	ContentId string // content id
}

Attachment represents an email attachment.

type Header struct {
	Key   string
	Value string
}

Header represents an additional email header.

type Message

type Message struct {
	To          []*mail.Address
	Cc          []*mail.Address
	Bcc         []*mail.Address
	ReplyTo     string
	Subject     string
	Body        string
	BodyType    string
	Headers     []Header
	Attachments map[string]*Attachment
	// contains filtered or unexported fields
}

Message represents a smtp message.

func HTMLMessage

func HTMLMessage(subject string, body string) *Message

HTMLMessage returns a new Message that can compose an HTML email with attachments

func TextMessage

func TextMessage(subject string, body string) *Message

TextMessage returns a new Message that can compose an email with attachments

func (*Message) AddBCC

func (m *Message) AddBCC(address *mail.Address) []*mail.Address

AddBCC add a bcc recipient

func (*Message) AddCC

func (m *Message) AddCC(address *mail.Address) []*mail.Address

AddCC add a cc recipient

func (*Message) AddHeader

func (m *Message) AddHeader(key string, value string) Header

AddHeader a Header to message

func (*Message) AddTO

func (m *Message) AddTO(address *mail.Address) []*mail.Address

AddTO add a recipient

func (*Message) Attach

func (m *Message) Attach(file string) error

Attach attaches a file.

func (*Message) AttachBuffer

func (m *Message) AttachBuffer(filename string, buf []byte, inline bool) error

AttachBuffer attaches a binary attachment.

func (*Message) Inline

func (m *Message) Inline(file string, cid string) error

Inline includes a file as an inline attachment.

func (*Message) Send

func (m *Message) Send() error

Send email with smtp protocol.

type TemplateData

type TemplateData struct {
	Title string       // html page title
}

Jump to

Keyboard shortcuts

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