email

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VerificationSubject is the subject for verification emails
	VerificationSubject = "Netsoc account verification"
	// EmailResetPasswordSubject is the subject for password reset emails
	ResetPasswordSubject = "Netsoc account password reset"
)

Variables

View Source
var (
	// EmailVerificationAPI is a template for an email with API-based verification
	VerificationAPI = template.Must(template.New("email_verification.txt").Parse(`Hi {{.User.FirstName}},

Thanks for signing up to Netsoc! Here's your verification token: {{.Token}}

Regards,
The Netsoc Team
`))
	// EmailVerificationUI is a template for an email with UI-based verification
	VerificationUI = template.Must(template.New("email_verification.txt").Parse(`Hi {{.User.FirstName}},

Thanks for signing up to Netsoc! Click the following link to verify your account: {{template "url" .}}

Regards,
The Netsoc Team
`))

	// ResetPasswordAPI is a template for an email with API-based password reset
	ResetPasswordAPI = template.Must(template.New("email_verification.txt").Parse(`Hi {{.User.FirstName}},

Here's your password reset token: {{.Token}}

If you didn't initiate the reset, you can ignore this email.

Regards,
The Netsoc Team
`))
	// ResetPasswordUI is a template for an email with UI-based password reset
	ResetPasswordUI = template.Must(template.New("email_verification.txt").Parse(`Hi {{.User.FirstName}},

Click the following link to reset your password: {{template "url" .}}

If you didn't initiate the reset, you can ignore this email.

Regards,
The Netsoc Team
`))
)

Functions

This section is empty.

Types

type Config

type Config struct {
	From      string
	ReplyTo   string `mapstructure:"reply_to"`
	VerifyURL string `mapstructure:"verify_url"`
	ResetURL  string `mapstructure:"reset_url"`
}

Config represents a Sender's configuration

type SMTPConfig

type SMTPConfig struct {
	Host           string
	Port           uint16
	ConnectTimeout time.Duration `mapstructure:"connect_timeout"`
	Username       string
	Password       string
	TLS            bool

	PasswordFile string `mapstructure:"password_file"`
}

type SMTPSender

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

func NewSMTPSender

func NewSMTPSender(c Config, smtpConfig SMTPConfig) (*SMTPSender, error)

func (*SMTPSender) Config

func (m *SMTPSender) Config() *Config

func (*SMTPSender) SendEmail

func (m *SMTPSender) SendEmail(tpl *template.Template, subject string, info UserInfo) error

SendEmail sends an email to a user

type Sender

type Sender interface {
	Config() *Config
	SendEmail(tpl *template.Template, subject string, info UserInfo) error
}

type UserInfo

type UserInfo struct {
	User  *models.User
	Token string
}

UserInfo represents information available to email templates

Jump to

Keyboard shortcuts

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