Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type SendRequest ¶
type SendRequest struct { From string `json:"from" binding:"required"` // Email source address. To []string `json:"to" binding:"required"` // List of destination email addresses. Subject string `json:"subject" binding:"required"` // Email subject. Body string `json:"body" binding:"required"` // Email body. }
SendRequest is a request to send an email to the specified 'to' addresses.
type SendStatus ¶
type SendStatus struct { ID string `json:"id" binding:"required"` // Email Message-ID header. Status string `json:"status" binding:"required"` // Request status. Failed []string `json:"failed" binding:"required"` // List of addresses that couldn't be reached. TimeCompleted int64 `json:"time_completed"` // Timestamp at SendRequest completion. }
SendStatus tracks the status of a SendRequest. If status is "completed", then Failed are the destination addresses that could not be reached.
func SendMail ¶
func SendMail(id string, req SendRequest) SendStatus
SendMail fulfills the SendRequest. This might take a while to complete if you specify too many email addresses. If you need immediate responses, use Sender struct instead.
type Sender ¶
type Sender struct {
// contains filtered or unexported fields
}
Sender maintains a queue of send requests and their status, and attempts to process them.
func (*Sender) Clear ¶
func (s *Sender) Clear()
Clear the SendRequest status cache. Queued requests are not affected, and will show up in the status queue once they're finished processing.
func (*Sender) Enqueue ¶
func (s *Sender) Enqueue(req SendRequest) string
Enqueue a request to the processing queue and return a reference ID. Returns an empty string if req.From is not a valid email address.
func (*Sender) GetStatus ¶
func (s *Sender) GetStatus(ref string) SendStatus
GetStatus returns the status of a request by looking up its reference ID.