{"record":{"id":"8b5734f5b1eb12e8","repo":"mickael-kerjean/filestash","slug":"cannot-send-mail-reason-s","errorCode":null,"errorMessage":"cannot send mail - reason=%s","messagePattern":"cannot send mail - reason=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/plugin/plg_authenticate_local/notify.go","lineNumber":51,"sourceCode":"\tcfg, err := getPluginData()\n\tif err != nil {\n\t\treturn err\n\t} else if cfg.GetMailSubject() == \"\" || cfg.GetMailBody() == \"\" {\n\t\treturn nil\n\t}\n\tm := gomail.NewMessage()\n\tm.SetHeader(\"From\", Config.Get(\"email.from\").String())\n\tm.SetHeader(\"To\", user.Email)\n\tm.SetHeader(\"Subject\", withTemplate(cfg.GetMailSubject(), user))\n\tm.SetBody(\"text/plain\", withTemplate(cfg.GetMailBody(), user))\n\td := gomail.NewDialer(\n\t\tConfig.Get(\"email.server\").String(),\n\t\tConfig.Get(\"email.port\").Int(),\n\t\tConfig.Get(\"email.username\").String(),\n\t\tConfig.Get(\"email.password\").String(),\n\t)\n\tif err := d.DialAndSend(m); err != nil {\n\t\treturn fmt.Errorf(\"cannot send mail - reason=%s\", err.Error())\n\t}\n\tLog.Info(\"plg_authenticate_simple::notification action=sent email=%s\", user.Email)\n\treturn nil\n}\n\nfunc withTemplate(in string, user User) string {\n\tvar b bytes.Buffer\n\ttmpl, err := template.New(\"app\").Parse(in)\n\tif err != nil {\n\t\tLog.Warning(\"plg_authenticate_simple::mail err=cannot_compile_template\")\n\t\treturn in\n\t}\n\ttmpl.Execute(&b, map[string]string{\n\t\t\"instance_url\": Config.Get(\"general.host\").String(),\n\t\t\"user\":         user.Email,\n\t\t\"password\":     user.Password,\n\t\t\"role\":         user.Role,\n\t})","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/mickael-kerjean/filestash/blob/78f756eb94ef383f1f1cd4bc3077a43a4d088ff0/server/plugin/plg_authenticate_local/notify.go#L33-L69","documentation":"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.","triggerScenarios":"Thrown at server/plugin/plg_authenticate_local/notify.go:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"78f756eb94ef383f1f1cd4bc3077a43a4d088ff0","analyzedAt":"2026-09-06T11:52:48.712Z","contentChangedAt":"2026-09-06T11:52:48.712Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}