email

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2016 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidHandle   = errors.New("invalid handle")
	ErrInvalidResource = errors.New("invalid resource")
	ErrInvalidAddress  = errors.New("invalid address")
)

Portable errors

Functions

func MatchHandle added in v0.4.0

func MatchHandle(pattern, handle string) bool

MatchHandle reports wether handle matches the handle pattern. The pattern syntax is:

'bob@example.com' matches a single address
'@example.com'    matches any addresses with domain example.com
'@'               matches any address

func MatchResource added in v0.4.0

func MatchResource(pattern, resource string) bool

MatchResource reports wether handle matches the handle pattern. The pattern syntax is:

'/private'  matches the resources
'/private/' matches any resource in the subtree
'domain.tld:8080/private/' matches any resource in the subtree with host and port

func SplitLocalDomain added in v0.4.0

func SplitLocalDomain(address string) (local, domain string, err error)

SplitLocalDomain splits an email address into local and domain.

Example
package main

import (
	"fmt"

	"github.com/namsral/multipass/services/email"
)

func main() {
	local, domain, err := email.SplitLocalDomain("bob@example.com")
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(local, domain)
}
Output:

bob example.com

func ValidHandle added in v0.4.0

func ValidHandle(value string) bool

ValidHandle reports wether value is a valid handle or handle pattern. The pattern syntax is:

'bob@example.com' matches a single address
'@example.com'    matches any addresses with domain example.com
'@'               matches any address

Types

type Options added in v0.3.0

type Options struct {
	FromAddr                     string
	SMTPAddr, SMTPUser, SMTPPass string
	SMTPClientName               string
	SMTPClientArgs               []string
	MailTemplate                 string
}

Options is used to construct a new UserService using the NewUserService function.

type UserService added in v0.3.0

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

UserService implements the UserService interface. Handles are interperted as email addresses.

func NewUserService added in v0.3.0

func NewUserService(opt Options) (*UserService, error)

NewUserService returns a new UserService instance with the given options.

func (*UserService) AddHandle added in v0.4.0

func (s *UserService) AddHandle(value string) error

AddHandle registers the given handle or handle pattern to be used in user authorization.

func (*UserService) AddResource added in v0.4.0

func (s *UserService) AddResource(value string) error

AddResource adds the given resource or resource pattern to be used in user authorization.

func (*UserService) Authorized added in v0.3.0

func (s *UserService) Authorized(handle, method, rawurl string) bool

Authorized returns true when an user identified with the given handle is authorized to access the resource at the given rawurl. Unknown resources are accessible to listed and unlisted user handlers.

func (*UserService) Close added in v0.3.0

func (s *UserService) Close() error

Close closes the channel to send mail messages.

func (*UserService) Listed added in v0.3.0

func (s *UserService) Listed(handle string) bool

Listed return true when the given address is listed.

func (*UserService) Notify added in v0.3.0

func (s *UserService) Notify(handle, loginurl string) error

Notify returns nil when the given login URL is successfully sent to the given email address.

Jump to

Keyboard shortcuts

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