{"record":{"id":"82fd69f59d0383ad","repo":"bytebase/bytebase","slug":"mail-from-failed","errorCode":null,"errorMessage":"MAIL FROM failed","messagePattern":"MAIL FROM failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/plugin/mailer/smtp.go","lineNumber":55,"sourceCode":"\t\treturn errors.Wrapf(err, \"failed to connect to SMTP server %s\", addr)\n\t}\n\tdefer client.Close()\n\n\tif s.config.Encryption == storepb.EmailSetting_SMTPConfig_STARTTLS {\n\t\ttlsConfig := &tls.Config{ServerName: s.config.Host}\n\t\tif err := client.StartTLS(tlsConfig); err != nil {\n\t\t\treturn errors.Wrap(err, \"STARTTLS failed\")\n\t\t}\n\t}\n\n\tif auth := s.auth(); auth != nil {\n\t\tif err := client.Auth(auth); err != nil {\n\t\t\treturn errors.Wrap(err, \"SMTP authentication failed\")\n\t\t}\n\t}\n\n\tif err := client.Mail(s.from); err != nil {\n\t\treturn errors.Wrap(err, \"MAIL FROM failed\")\n\t}\n\tfor _, to := range req.To {\n\t\tif err := client.Rcpt(to); err != nil {\n\t\t\treturn errors.Wrapf(err, \"RCPT TO %s failed\", to)\n\t\t}\n\t}\n\n\tw, err := client.Data()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"DATA command failed\")\n\t}\n\tmsg := s.buildMessage(req)\n\tif _, err := w.Write([]byte(msg)); err != nil {\n\t\treturn errors.Wrap(err, \"failed to write message\")\n\t}\n\tif err := w.Close(); err != nil {\n\t\treturn errors.Wrap(err, \"failed to close data writer\")\n\t}","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/plugin/mailer/smtp.go#L37-L73","documentation":"The SMTP server rejected the MAIL FROM command with the configured envelope sender address (s.from). The wrapped error carries the server's 5xx/4xx response. This happens before any recipient is transmitted, so it indicates the server refuses the sender, not the recipient.","triggerScenarios":"Send called with s.from not accepted by the server: address not authorized for the authenticated user, malformed address, or relay denial for unauthenticated senders.","commonSituations":"From address domain not verified with the SMTP provider (SES, SendGrid domain verification); M365/Gmail rejecting a From different from the authenticated account; empty or malformed From in email settings; server restricts MAIL FROM to specific verified identities.","solutions":["Set From to an address verified/authorized with the SMTP provider (match the authenticated account for Gmail/M365).","Complete domain/address verification in the provider console (SES identity, SendGrid sender authentication).","Check the wrapped SMTP response code for the exact rejection reason and fix accordingly.","Validate the From address syntax in settings (no spaces, proper user@domain format)."],"exampleFix":"// before: unverified sender domain\nFrom: \"bytebase@random-domain.net\"\n// after\nFrom: \"bytebase@verified-company-domain.com\"","handlingStrategy":"validation","validationCode":"import \"net/mail\"\nfunc fromAddressValid(from string) bool {\n    _, err := mail.ParseAddress(from)\n    return err == nil\n}\n// plus: confirm From domain is verified with the SMTP provider before first send","typeGuard":null,"tryCatchPattern":"if err := sender.Send(ctx, req); err != nil {\n    if strings.Contains(err.Error(), \"MAIL FROM failed\") {\n        // surface wrapped SMTP response; check sender authorization on the provider\n    }\n}","preventionTips":["Always configure From as a domain verified with the SMTP provider.","Keep From equal to (or an alias of) the authenticated account for Gmail/M365.","Send a test email with the exact From address during setup."],"tags":["smtp","email","sender"],"backgroundTag":"smtp-rejected-sender","analyzedSha":"1870550677fe08f0d2a78c07acd27541464eb945","analyzedAt":"2026-09-06T21:16:13.665Z","contentChangedAt":"2026-09-06T21:16:13.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}