send

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package send submits messages over SMTP.

Index

Constants

View Source
const GraphHost = "graph.microsoft.com"

GraphHost marks an Endpoint that sends through Microsoft Graph with its AccessToken, for a mailbox whose SMTP AUTH is disabled.

Variables

View Source
var ErrUncertain = errors.New("send: the server may have accepted the message")

ErrUncertain means the whole message reached the server but its verdict did not come back: it may have been accepted. Retrying could deliver it twice.

View Source
var GraphURL = "https://" + GraphHost + "/v1.0/me/sendMail"

GraphURL is Graph's sendMail; tests replace it.

Functions

func Send

func Send(ctx context.Context, ep conn.Endpoint, from string, rcpts []string, raw []byte) error

Send submits raw to rcpts, stopping at the first refused recipient. An error that is not ErrUncertain happened before the server could accept the message, so retrying is safe; a *RejectedError is the server's refusal. Cancelling ctx closes the connection.

func SendGraph added in v1.32.0

func SendGraph(ctx context.Context, token string, rcpts []string, raw []byte) error

SendGraph submits raw to rcpts through Graph's sendMail, with the same errors as Send: ErrUncertain once the whole request went out without an answer, conn.ErrAuthFailed for a refused token, a *RejectedError (5xx) for a refused message. Graph takes recipients from the headers, so rcpts not in To or Cc are added as Bcc to the copy Graph gets (Exchange strips it).

Types

type RejectedError added in v1.14.0

type RejectedError struct {
	// Stage is the refused command: "MAIL", "RCPT" or "DATA".
	Stage string
	// Recipient is the refused address at RCPT, "" at the other stages.
	Recipient string
	// Code is the reply code, such as 550: 4xx refuses for now, 5xx for good.
	Code int
	// Enhanced is the enhanced status code, such as "5.1.1"; "" if the server sent none.
	Enhanced string
	// Message is the server's reply text as it sent it.
	Message string
}

RejectedError is the server's refusal of the message at MAIL FROM, at a RCPT TO or at the end of DATA. The server has not accepted the message.

func (*RejectedError) Error added in v1.14.0

func (e *RejectedError) Error() string

Jump to

Keyboard shortcuts

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