Documentation
¶
Overview ¶
Package send submits messages over SMTP.
Index ¶
Constants ¶
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 ¶
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.
var GraphURL = "https://" + GraphHost + "/v1.0/me/sendMail"
GraphURL is Graph's sendMail; tests replace it.
Functions ¶
func Send ¶
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
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