Documentation
¶
Index ¶
Constants ¶
const ( SMTP = 1 MailGun = 2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MailData ¶
type MailData struct {
ToName string // The name of the recipient.
ToAddress string // The email address of the recipient.
FromName string // The name of the sender.
FromAddress string // The email address of the sender.
ReplyTo string // The reply-to email address.
AdditionalTo []string // Additional TO recipients.
Subject string // The subject of the email message.
Content template.HTML // The content of the message, as HTML.
ContentType string // Optional: "text/html" (default), "text/plain", "application/xml", etc.
Template string // The template to use. If not specified, will use a simple default template.
CC []string // A slice of CC recipient emails.
BCC []string // A slice of BCC recipient emails.
Attachments []string // A slice of attachments, which must exist on disk (i.e. []string{"./files/myfile.pdf"}).
Data map[string]any // Data which is to be passed to the Go template.
InlineImages []string // A slice of images to be inlined in the email. PNG is preferred.
ServerURL string // The URL of the server (for backlinks in message).
}
MailData holds all information for a given message.
type MailDispatcher ¶
type MailDispatcher struct {
JobQueue chan MailProcessingJob // The channel we send work to.
ErrorChan chan error // The channel we send errors (or nil) to.
// contains filtered or unexported fields
}
MailDispatcher is the main interface to this package. Calling new returns an instance onf this type. This type has one method, Send, which is used to send an email.
func New ¶
func New(s Service) (*MailDispatcher, error)
New returns a new mail dispatcher, with a job queue channel and error channel. Send email by calling the Send method on the returned *MailDispatcher.
func (*MailDispatcher) Run ¶
func (md *MailDispatcher) Run()
Run runs the workers in our worker pool.
func (*MailDispatcher) Send ¶
func (md *MailDispatcher) Send(msg MailData)
Send takes a msg in postal.MailData format, wraps it in a postal.MailProcessingJob and send it to the job queue for delivery.
type MailMessage ¶
type MailMessage struct {
MailData MailData
}
MailMessage is a simple wrapper for MailData.
type MailProcessingJob ¶
type MailProcessingJob struct {
MailMessage MailData
}
MailProcessingJob is the unit of work to be performed. We wrap this type around a Video, which has all the information we need about the input source and what we want the output to look like.
type Service ¶
type Service struct {
Method int // How to send the message: postal.SMTP or postal.MailGun.
ServerURL string // The URL of the server mail is sent from.
SMTPServer string // The SMTP server.
SMTPPort int // The SMTP server's port.
SMTPUser string // The username for the SMTP server.
SMTPPassword string // The password for the SMTP server.
ErrorChan chan error // A channel to send errors (or nil) to.
MaxWorkers int // Maximum number of workers in the pool.
MaxMessages int // How big the buffer should be for the JobQueue.
Domain string // The domain used to send mail.
APIKey string // The API key for mailgun.
SendingFromEU bool // If using mailgun and sending from EU, set to true.
TemplateDir string // Where templates are stored.
// contains filtered or unexported fields
}
Service is the type used to create a MailDispatcher.