smtp

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 7 Imported by: ? 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 smtp sends mail over SMTP with the whole exchange bounded by a context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendMail

func SendMail(ctx context.Context, addr string, auth smtp.Auth, from string, to []string, msg []byte) error

SendMail sends msg from from to each address in to via the SMTP server at addr, which must include a port. It's the equivalent of smtp.SendMail, except the whole exchange is bounded by ctx: if ctx is done before the message is sent, the connection is closed and ctx's error is returned. ctx should normally carry a deadline, as nothing else stops a server that stops responding.

The connection is upgraded with STARTTLS if the server offers it, verifying the server's certificate against addr's host. If auth is non-nil the server must offer AUTH, and auth is used to authenticate; if it's nil, no authentication is attempted.

Once the server has accepted the message, it counts as sent: if the QUIT that follows fails, or ctx is done before it completes, the failure is logged and SendMail returns nil so that a retry doesn't deliver the message again.

Types

This section is empty.

Jump to

Keyboard shortcuts

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