The mail delivery client
In go-mail the Client
is responsible for the mail delivery with remote mail servers that communicate via the
SMTP protocol.
|
|
To create a new Client
, you can use the NewClient()
method. As first argument it requires the hostname of the
sending SMTP server. Optionally you can provide a list of Option
funcionts. These option functions can be used
to override the default settings of the Client
.
Check the Options documentation for in-depth details to all available Options.
|
|
Close()
closes the connection to the SMTP server the Client
is connected to. It returns an error
in case the
Client
has no active connection or if closing the connection fails.
|
|
|
|
The DialAndSend()
method is an alias for DialAndSendWithContext() with a default
context.Background
context. DialAndSend()
takes a list of Msg
pointer as argument(s) and returns
an error
in case any of the performed actions fails.
|
|
|
|
The DialAndSendWithContext()
is a one-for-all shortcut method on the Client
. Once the Client
is created,
calling the DialAndSendWithContext()
method will have it connect to the configured server, send out the
given mail Msg
and finalize by closing the connection again.
The first argument of the method is a context.Context
followed by a list of one or more Msg
pointers.
DialAndSendWithContext()
does return an error
in case any of the performed actions fails.