mailman

package
v0.0.0-...-43bb807 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2022 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package mailman provides an HTTP Oauth2 based module that sends email using Gmail API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	App      *oauth2.App
	StateKey []byte
	Tokens   Tokens
}

Config contains configuration for a mailman.

type Mailman

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

Mailman is a http server module for sending emails using gmail's OAuth2 API.

func New

func New(c *Config) *Mailman

New creates a new mailman.

func (*Mailman) Router

func (m *Mailman) Router() *aries.Router

Router returns the mailman module router.

func (*Mailman) Send

func (m *Mailman) Send(
	ctx context.Context, from string, body []byte,
) (string, error)

Send sends an email. Needs to setup OAuth2 first.

type SendRequest

type SendRequest struct {
	From string
	Body []byte
}

SendRequest is an request for sending a mail.

type Tokens

type Tokens interface {
	Get(ctx context.Context, email string) (*goauth2.Token, error)
	Set(ctx context.Context, email string, t *goauth2.Token) error
}

Tokens is an interface that gets and fetches an OAuth2 refresh token.

Jump to

Keyboard shortcuts

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