{"record":{"id":"8035c1a82b25c1de","repo":"Billionmail/BillionMail","slug":"email-sender-not-configured","errorCode":null,"errorMessage":"Email Sender not configured","messagePattern":"Email Sender not configured","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/mail_service/sending.go","lineNumber":146,"sourceCode":"\t\t// e.SNI, _ = public.DockerEnv(\"BILLIONMAIL_HOSTNAME\")\n\t}\n\n\treturn e\n}\n\nfunc NewEmailSenderWithLocal(email string) (es *EmailSender, err error) {\n\tes = NewEmailSender()\n\n\tes.Email = email\n\tes.UserName = email\n\tes.Password, err = PasswordPlainByEmail(context.Background(), email)\n\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif !es.IsConfigured() {\n\t\terr = errors.New(\"Email Sender not configured\")\n\t\treturn\n\t}\n\n\treturn\n}\n\n// PasswordPlainByEmail\nfunc PasswordPlainByEmail(ctx context.Context, email string) (string, error) {\n\tval, err := g.DB().Model(\"mailbox\").Where(\"username\", email).Value(\"password_encode\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"query password failed: %w\", err)\n\t}\n\tif val.IsEmpty() {\n\t\treturn \"\", fmt.Errorf(\"password not found for %s\", email)\n\t}\n\trawHex, err := hex.DecodeString(val.String())\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"hex decode failed: %w\", err)","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/mail_service/sending.go#L128-L164","documentation":"NewEmailSenderWithLocal builds an EmailSender from local mailbox config, then requires es.IsConfigured() (host/port/credentials present). If the underlying settings query succeeds but yields no usable SMTP configuration, it returns 'Email Sender not configured'.","triggerScenarios":"Calling SendMail, SendTestEmail, ApiMailBatchSend, sendConfirmationEmail, or recordApiMailLog when no email sender (SMTP host/user/password) has been set up in the system settings.","commonSituations":"Fresh BillionMail install where the admin never configured the mail sender; settings row deleted or keys emptied; environment where outbound SMTP was intentionally disabled.","solutions":["Configure the Email Sender (SMTP host, port, username, password) in the admin settings UI.","Verify the settings table actually contains the sender keys with non-empty values.","Guard call sites: check IsConfigured() before invoking send paths to fail gracefully.","If sending is not intended on this instance, skip the send call instead of treating this as a runtime fault."],"exampleFix":"// before\nerr := SendMail(ctx, msg)\n// after\nif !mail_service.IsEmailSenderConfigured(ctx) {\n    return errors.New(\"please configure the Email Sender in settings before sending\")\n}\nerr := SendMail(ctx, msg)","handlingStrategy":"validation","validationCode":"es := mail_service.NewEmailSender()\nif es == nil || !es.IsConfigured() {\n    return errors.New(\"Email Sender is not configured: set SMTP host/port/credentials in settings first\")\n}","typeGuard":null,"tryCatchPattern":"if err := SendTestEmail(ctx); err != nil {\n    if strings.Contains(err.Error(), \"Email Sender not configured\") {\n        return fmt.Errorf(\"cannot send: complete SMTP setup in admin settings (%w)\", err)\n    }\n    return err\n}","preventionTips":["Complete the Email Sender setup wizard right after installation.","Add a startup check that warns when the sender is unconfigured.","Gate send endpoints behind a config-readiness check."],"tags":["smtp","configuration","email","mail-service"],"backgroundTag":"email-sender-not-configured","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"}