The smtp package provides the basic functionality to interact with the SMTP server. The Dial function provides the client. The most significant methods of the client are Mail, which sets the sender mail, Rcpt, which sets the recipients mail, and Data, which provides the Writer, where the content of the mail can be written. Finally, the Quit method sends QUIT and closes the connection to the server.
The previous example uses a secured connection to the SMTP server so the Auth method of the client is utilized to set the authentication, and the StartTLS method is called to start a secured connection to the server.