Documentation ¶
Overview ¶
Package mails provides a simple interface with the smtp library
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CustomClient ¶
type CustomClient struct {
// contains filtered or unexported fields
}
CustomClient : Modelizes the constants of a connection : an actual client, and a sender
Example ¶
// Create a connection client, err := NewCustomClient("sender@mail.com", "mail.server.com", "25", "username", "password") if err != nil { fmt.Println(err) } // Some reused variables recipient1 := "first@recipient.com" recipient2 := "second@recipient.com" recipient3 := "third@recipient.com" subject := "Mail example" message := `Hello, this is a mail example. It's not like the cactus is going to be jealous or anything...` // Send a first mail, without attachments err = client.Send([]string{recipient1, recipient2}, subject, message, []string{}, []string{}, [][]byte{}) if err != nil { fmt.Println(err) } // Just some test data fileA := []byte{'A'} fileB := []byte{'B'} // Send a second mail, with some attachments err = client.Send([]string{recipient1, recipient3}, subject, message, []string{"text/plain", "image/gif"}, []string{"email.go", "testdata/testImg.gif"}, [][]byte{fileA, fileB}) if err != nil { fmt.Println(err) } // Close the connection err = client.Close() if err != nil { fmt.Println(err) }
Output:
func NewCustomClient ¶
func NewCustomClient(sender, host, port, username, password string) (*CustomClient, error)
NewCustomClient starts up a custom client.
func (*CustomClient) Close ¶
func (c *CustomClient) Close() error
Close the connection of CustomClient
Click to show internal directories.
Click to hide internal directories.