goreleaser/goreleaser · error
SMTP: missing smtp.host or $SMTP_HOST
Error message
SMTP: missing smtp.host or $SMTP_HOST
What it means
Sentinel error errNoHost, returned by the SMTP config loader when the resolved `host` is empty — i.e. neither `smtp.host` in .goreleaser.yaml nor the $SMTP_HOST environment variable was set. Without a relay host the mail cannot be sent, so config validation fails fast.
Source
Thrown at internal/pipe/smtp/smtp.go:100
// This is only needed when SSL/TLS certificate is not valid on server.
// In production this should be set to false.
d.TLSConfig = &tls.Config{InsecureSkipVerify: ctx.Config.Announce.SMTP.InsecureSkipVerify}
// Now send E-Mail
if err := d.DialAndSend(m); err != nil {
return err
}
log.Infof("The mail has been send from %s to %s\n", ctx.Config.Announce.SMTP.From, receivers)
return nil
}
var (
errNoPort = errors.New("SMTP: missing smtp.port or $SMTP_PORT")
errNoUsername = errors.New("SMTP: missing smtp.username or $SMTP_USERNAME")
errNoHost = errors.New("SMTP: missing smtp.host or $SMTP_HOST")
)
func getConfig(smtp config.SMTP) (Config, error) {
cfg := Config{
Host: smtp.Host,
Port: smtp.Port,
Username: smtp.Username,
}
if err := env.Parse(&cfg); err != nil {
return cfg, fmt.Errorf("SMTP: %w", err)
}
if cfg.Username == "" {
return cfg, errNoUsername
}
if cfg.Host == "" {
return cfg, errNoHost
}
if cfg.Port == 0 {View on GitHub (pinned to f5edd73956)
Solutions
- Set `announce.smtp.host` in .goreleaser.yaml (e.g. smtp.example.com).
- Export $SMTP_HOST in your environment/CI.
- Verify YAML indentation so `host` is nested directly under `announce.smtp`.
Example fix
# before
announce:
smtp:
port: 587
from: ci@example.com
# after
announce:
smtp:
host: smtp.example.com
port: 587
from: ci@example.com Defensive patterns
Strategy: validation
Validate before calling
if os.Getenv("SMTP_HOST") == "" {
fmt.Println("set announce.smtp.host or export SMTP_HOST before running goreleaser")
} Try / catch
if err := Pipe{}.Run(ctx); err != nil {
if errors.Is(err, errNoHost) {
log.Fatal("SMTP announce: missing smtp.host / $SMTP_HOST")
}
log.Fatal(err)
} Prevention
- Define host, port, username, from/receivers as a complete set in one config block.
- Keep SMTP settings in a shared .env sourced by both local and CI runs.
- Verify YAML nesting: host must sit directly under announce.smtp.
When it happens
Trigger: `announce.smtp` block present in .goreleaser.yaml but `host` field empty and $SMTP_HOST unset when announcing.
Common situations: Users add the announce pipe with only from/to/receivers configured; migrating between environments where $SMTP_HOST was defined locally but not in CI; YAML indentation mistakes putting host at the wrong level.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- SMTP: missing smtp.port or $SMTP_PORT
- SMTP: missing smtp.username or $SMTP_USERNAME
- chocolatey requires at least one windows archive
- 'server' is a required config key
- 'category_id' is a required config key
AI-assisted analysis of goreleaser/goreleaser@f5edd73956 (2026-09-05).
Data as JSON: /api/errors/ac8e92e1286a0715.
Report an issue: GitHub.