yasmtp

package module
v0.0.0-...-7257645 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

README

Yet Another SMTP client

Created for simplare SMTP client usage, as most of the time you simply want to send email from your gmail account.

Additionally it handles context - which does not come by default from net/smtp.

Example

package main

func main() {
	ctx := context.Background()
	err := SendHTML(ctx, &Input{
		From: From{
			Email:          "your_gmail_acc@gmail.com",
			Password:       "your_gmail_acc_password",
			ServerHostPort: "smtp.gmail.com:587",
		},
		To: []To{{
			Email: "reciver_email@example.com",
		}},
		Msg: Message{
			Subject: "Your email subject",
			Body:    "Some email body",
		},
	})
    if err != nil {
        panic(err)
    }
}

aaaand that's it.

TODO:

[] option for local testing [] handling non-html

Documentation

Index

Constants

View Source
const (
	GmailSMTPHostPort = "smtp.gmail.com:587"
	MessageIDHeader   = "Message-ID"
)

Variables

This section is empty.

Functions

func SendHTML

func SendHTML(ctx context.Context, i *Input) error

Types

type From

type From struct {
	ServerHostPort string `validate:"required"`
	Password       string `validate:"required"`
	Email          string `validate:"email,required"`
	Name           string
}

type Input

type Input struct {
	From              From
	To                []To
	Bcc               []To
	Cc                []To
	Msg               Message
	AdditionalHeaders map[string]string
}

type Message

type Message struct {
	Id      string
	Subject string
	Body    string
}

type To

type To struct {
	Email string `validate:"email,required"`
	Name  string
}

Jump to

Keyboard shortcuts

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