mickael-kerjean/filestash · error
cannot send mail - reason=%s
Error message
cannot send mail - reason=%s
What it means
Wraps a failure from gomail's DialAndSend in sendInvitateMail. It fires when the SMTP dial or send fails — unreachable email server, wrong port/credentials, TLS rejection, or recipient refusal — after the mail subject/body have been templated for the user. Raised to UserManagementHandler, aborting the invitation/notification email.
Source
Thrown at server/plugin/plg_authenticate_local/notify.go:51
cfg, err := getPluginData()
if err != nil {
return err
} else if cfg.GetMailSubject() == "" || cfg.GetMailBody() == "" {
return nil
}
m := gomail.NewMessage()
m.SetHeader("From", Config.Get("email.from").String())
m.SetHeader("To", user.Email)
m.SetHeader("Subject", withTemplate(cfg.GetMailSubject(), user))
m.SetBody("text/plain", withTemplate(cfg.GetMailBody(), user))
d := gomail.NewDialer(
Config.Get("email.server").String(),
Config.Get("email.port").Int(),
Config.Get("email.username").String(),
Config.Get("email.password").String(),
)
if err := d.DialAndSend(m); err != nil {
return fmt.Errorf("cannot send mail - reason=%s", err.Error())
}
Log.Info("plg_authenticate_simple::notification action=sent email=%s", user.Email)
return nil
}
func withTemplate(in string, user User) string {
var b bytes.Buffer
tmpl, err := template.New("app").Parse(in)
if err != nil {
Log.Warning("plg_authenticate_simple::mail err=cannot_compile_template")
return in
}
tmpl.Execute(&b, map[string]string{
"instance_url": Config.Get("general.host").String(),
"user": user.Email,
"password": user.Password,
"role": user.Role,
})View on GitHub (pinned to 78f756eb94)
Solutions
- Verify email.server, email.port, email.username, email.password and email.from in the config are correct
- Test SMTP connectivity (telnet/openssl s_client) to the mail server from the server host
- Check the mail provider for rate limits or blocked recipient addresses
- Log the underlying gomail error detail (the %s reason) to distinguish dial vs send failures
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at server/plugin/plg_authenticate_local/notify.go:51 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of mickael-kerjean/filestash@78f756eb94 (2026-09-06).
Data as JSON: /api/errors/8b5734f5b1eb12e8.
Report an issue: GitHub.