mails

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2016 License: MIT Imports: 11 Imported by: 0

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

func (*CustomClient) Send

func (c *CustomClient) Send(receivers []string, subject, message string, extensions, filenames []string, files [][]byte) error

Send a mail with the custom client. Returns nil on success.

Jump to

Keyboard shortcuts

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