email

package
v4.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package email simple email sender

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mail

type Mail interface {
	// Login login to SMTP server
	Login(username, password string)
	// Send send email
	Send(frAddr, toAddr, frName, toName, subject, content string, optfs ...SendOption) (err error)
}

Mail is a simple email sender

Example
sender := NewMail("smtp_host", 53)
if err := sender.Send(
	"fromAddr",
	"toAddr",
	"frName",
	"toName",
	"Title",
	"Content",
); err != nil {
	log.Shared.Error("try to send email got error", zap.Error(err))
}
Output:

type MailT

type MailT struct {
	// contains filtered or unexported fields
}

MailT easy way to send basic email

func NewMail

func NewMail(host string, port int) *MailT

NewMail create Mail with SMTP host and port

func (*MailT) BuildMessage

func (m *MailT) BuildMessage(msg string) string

BuildMessage implement

func (*MailT) Login

func (m *MailT) Login(username, password string)

Login login to SMTP server

func (*MailT) Send

func (m *MailT) Send(frAddr, toAddr, frName, toName, subject, content string, optfs ...SendOption) (err error)

Send send email

type SendOption

type SendOption func(*mailSendOpt)

SendOption is a function to set option for Mail.Send

func WithMailSendDialer

func WithMailSendDialer(dialerFact func(host string, port int, username, passwd string) Sender) SendOption

WithMailSendDialer set gomail.Dialer

type Sender

type Sender interface {
	DialAndSend(m ...*gomail.Message) error
}

Sender create gomail.Dialer

Jump to

Keyboard shortcuts

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