{"record":{"id":"61450fdd2d0da4a1","repo":"Billionmail/BillionMail","slug":"s","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/controller/settings/settings_v1_set_blacklist_alert_settings.go","lineNumber":111,"sourceCode":"\t\t\treturn fmt.Errorf(\"invalid recipient email format: %s\", recipient)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc testSMTPConnectionWithRelay(ctx context.Context, settings *v1.SetBlacklistAlertSettingsReq) error {\n\t//g.Log().Infof(ctx, \"Testing SMTP connection to %s:%d\", settings.SMTPServer, settings.SMTPPort)\n\n\tresult := relay.TestSmtpConnection(\n\t\tsettings.SMTPServer,\n\t\tfmt.Sprintf(\"%d\", settings.SMTPPort),\n\t\tsettings.SenderEmail,\n\t\tsettings.SMTPPassword,\n\t)\n\n\tif !result.Success {\n\t\treturn fmt.Errorf(\"%s\", result.Message)\n\t}\n\n\t//g.Log().Infof(ctx, \"SMTP connection test successful: %s\", result.Message)\n\treturn nil\n}\n\nfunc sendTestEmailWithMailService(ctx context.Context, settings *v1.SetBlacklistAlertSettingsReq) error {\n\t//g.Log().Infof(ctx, \"Sending test email to %v\", settings.RecipientList)\n\n\tsubject := \"Blacklist Alert Test - BillionMail\"\n\tbody := buildTestEmailHTML(settings)\n\n\tsender := mail_service.NewEmailSender()\n\tsender.Host = settings.SMTPServer\n\tsender.Port = fmt.Sprintf(\"%d\", settings.SMTPPort)\n\tsender.Email = settings.SenderEmail\n\tsender.UserName = settings.SenderEmail\n\tsender.Password = settings.SMTPPassword","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/controller/settings/settings_v1_set_blacklist_alert_settings.go#L93-L129","documentation":"testSMTPConnectionWithRelay runs an external SMTP connection test; when result.Success is false the tool's own message is rewrapped verbatim (fmt.Errorf(\"%s\", result.Message)) and returned to the caller. The text after this prefix is whatever the connection test reported (auth failure, DNS failure, timeout, etc.).","triggerScenarios":"SetBlacklistAlertSettings with testMode triggering testSMTPConnectionWithRelay where the relay probe fails — wrong host/port, bad credentials, unreachable server, or TLS negotiation failure.","commonSituations":"SMTP server hostname has a typo; firewall blocks outbound port 587/465; credentials rotated; the relay binary is missing or fails to start so result.Message carries its error output.","solutions":["Read result.Message in the returned error — it names the actual cause; fix that underlying issue.","Verify SMTPServer resolves and the SMTPPort is reachable from the server (nc/telnet host port).","Re-check SMTPUser/SMTPPassword against the mail provider.","Fall back to sendTestEmailWithMailService (internal mail service) if the external relay path is not required."],"exampleFix":"// before\nif !result.Success { return fmt.Errorf(\"%s\", result.Message) }\n// after\nif !result.Success {\n    return fmt.Errorf(\"SMTP connection test failed: %s\", result.Message) // add context\n}","handlingStrategy":"try-catch","validationCode":"// pre-check reachability before saving settings\nconst up = await fetch(`/api/diag/tcp?host=${host}&port=${port}`).then(r => r.ok)\nif (!up) throw new Error('SMTP host unreachable; fix host/port before saving')","typeGuard":null,"tryCatchPattern":"err := SetBlacklistAlertSettings(ctx, req)\nif err != nil {\n  // err text is the raw relay/test-tool message; log it verbatim for diagnosis\n  log.Printf(\"blacklist alert SMTP test failed: %v\", err)\n  return echoNewError(err.Error())\n}","preventionTips":["Read result.Message — it contains the true underlying cause","Pre-test connectivity (DNS + TCP) from the server before persisting settings","Keep fallback to the internal mail-service path when the relay probe fails"],"tags":["smtp","network","relay"],"backgroundTag":"smtp-connection-test-failed","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}