Skip to content
Mail Management

Mail Management

Mail Management sends e-mails, for example the verification and password reset mails of User Management. Mails are put into an outgoing queue and delivered by a background scheduler through an SMTP server, failed deliveries are retried. The admin UI shows statistics, the queue, the health of the SMTP servers and a test form.

Mail dashboard

Enable

mails := std.Must(cfg.MailManagement()) // application.MailManagement

Mail Management is always enabled, because Session Management depends on it. It enables Secret and Template Management and installs the built-in mail templates as a template project.

application.MailManagement has the fields UseCases mail.UseCases and Pages uimail.Pages.

Configure an SMTP server

  1. Open the vault in the admin center (Tresor & Fremdsysteme) and create a secret of the type SMTP Postausgangsserver with host, port, user, password and sender address.
  2. Share the secret with the group System (group.System).

Without a shared SMTP secret, mails stay in the queue. If several SMTP secrets are shared, Mail.SmtpHint selects one by name or secret ID; otherwise the first one is used.

Send a mail

import (
	netmail "net/mail"

	"go.wdy.de/nago/application/mail"
)

_, err := mails.UseCases.SendMail(subject, mail.Mail{
	To:      []netmail.Address{{Address: "jane@example.com"}},
	Subject: "Hello",
	Parts:   []mail.Part{mail.NewTextPart("Hello Jane")},
})
if err != nil {
	return err
}

mail.NewHtmlPart and mail.NewAttachmentPart add HTML and attachments. Code which runs without a subject can publish a mail.SendMailRequested event on the event bus instead; it is sent as the system user.

The configurator has helpers for the built-in flows: cfg.SendVerificationMail(uid), cfg.SendPasswordResetMail(mail) and cfg.SendMailTemplate(to, tpl, subjectName, bodyName, model), which renders a template and sends it.

Use cases

Use caseDescription
SendMailPuts a mail into the outgoing queue.
FindOutgoingIDsLists the IDs of outgoing mails, latest first, with an optional filter.
FindOutgoingByIDLoads an outgoing mail with content and delivery attempts.
DeleteOutgoingByIDRemoves a mail from the queue.
RetryOutgoingPuts mails back into the queue and keeps their attempt history.
ResendOutgoingQueues a new copy of a mail.
StatisticsAggregates delivery statistics, problems and SMTP server health.

Outgoing is deprecated, use the use cases above.

Permissions

PermissionAllows to
nago.mail.sendsend mails
nago.mail.outgoing.find_allview the outgoing queue
nago.mail.outgoing.find_by_idview an outgoing mail
nago.mail.outgoing.delete_by_iddelete an outgoing mail
nago.mail.outgoing.updateupdate an outgoing mail
nago.mail.outgoing.retryretry a failed delivery
nago.mail.outgoing.resendresend a mail
nago.mail.statisticsview statistics and SMTP health
nago.mail.init_default_templatesset the default templates

UI

PathPage
admin/maildashboard with statistics
admin/mail/outgoingoutgoing queue
admin/mail/outgoing/detaila single mail
admin/mail/smtpSMTP servers and their health
admin/mail/testsend a test mail

The admin center shows them in the group E-Mail und SMTP.

Related