Documentation ¶
Overview ¶
Package dish provides services and types for sending mails.
Package dish provides services and types for sending mails.
Index ¶
Constants ¶
const (
FromName string = "FoodUnit"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service executes mail-related business logic and use cases. It is also responsible for accessing the model storage under consideration of all business rules.
func New ¶
NewService creates a new Service instance utilizing the given storage objects. The storage objects need to be ready to use for the service.
func (*Service) Send ¶
Send creates an e-mail and attempts to send it via the SendGrid API. It will replace all placeholders of Settings.Variables in the mail subject and body.
For instance, the subject may look like this: `Welcome to FoodUnit, {{name}}!` To replace {{name}} with a real value, you should provide settings like this:
settings := mail.Settings{ Subject: `Welcome to FoodUnit, {{name}}!`, Variables: map[string]string{ "name": username, } } mailService.Send(&settings)
Send will automatically replace the map key with the associated value. Note that the key must not include the curly brackets.
type Settings ¶
type Settings struct { From string `json:"from"` To string `json:"to"` ToName string `json:"to_name"` Subject string `json:"subject"` Body string `json:"body"` Variables map[string]string `json:"variables"` }
Settings provides basic configuration values for sending an e-mail. It also holds placeholders which will be replaced with the mapped values.