smtpclient

package
v0.0.0-...-30b4a77 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2016 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package smtpclient wraps pkg/smtp to make it easy to use.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoHost is returned if no delivery host could be found
	ErrNoHost = errors.New("smtpclient: no host")
	// ErrNoTLS is returned if TLS was not offered though it was expected
	ErrNoTLS = errors.New("smtpclient: no TLS")
	// ErrNoAuth is returned if authentication was not offered though it was expected
	ErrNoAuth = errors.New("smtpclient: no AUTH")
	// ErrFinal is returned if a resend-attempt will fail
	ErrFinal = errors.New("smtpclient: final error")
	// ErrRetry is retured if a resend-attempt might work
	ErrRetry = errors.New("smtpclient: retry")
)

Functions

func GetMailDomain

func GetMailDomain(addr string) string

GetMailDomain returns the domain of an email address

func LookupMX

func LookupMX(domain string) string

LookupMX returns the primary MX for a domain

Types

type MailClient

type MailClient struct {
	HeloHost       string // How to identify in greetings, can be ""
	CACert         []byte // CA Certificate to enforce. Can be nil to not enforce TLS
	NoSSL          bool   // disable all SSL
	User, Password string // Authentication
	Port           int    // SMTP port, defaults to 25
	SmartHost      string // Smarthost, for sending via a destination independent smarthost
	LastError      error  // Last error encountered
	LastErrorCode  int    // Last SMTP error code
}

MailClient implements a trivial SMTP client

func (*MailClient) SendMail

func (mc *MailClient) SendMail(to, from string, mail []byte) error

SendMail will send mail to "to" using "from" as sender. Mail must already correctly formatted since SendMail only takes care of SMTP. Errors returned signal if a retry might work.

Jump to

Keyboard shortcuts

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