usememos/memos · error

from email is required

Error message

from email is required

What it means

Returned by Config.Validate() when FromEmail is empty. The sender address is mandatory for the SMTP MAIL FROM command and the message headers, so a Config without it is rejected before connecting. Like the host and port checks, this is a fail-fast guard on incomplete mailer configuration.

Source

Thrown at internal/email/config.go:39

	FromEmail string
	// FromName is the display name that will appear in the "From" field
	FromName string
	// UseTLS enables STARTTLS encryption (recommended for port 587)
	UseTLS bool
	// UseSSL enables SSL/TLS encryption (for port 465)
	UseSSL bool
}

// Validate checks if the configuration is valid.
func (c *Config) Validate() error {
	if c.SMTPHost == "" {
		return errors.New("SMTP host is required")
	}
	if c.SMTPPort <= 0 || c.SMTPPort > 65535 {
		return errors.New("SMTP port must be between 1 and 65535")
	}
	if c.FromEmail == "" {
		return errors.New("from email is required")
	}
	return nil
}

// GetServerAddress returns the SMTP server address in the format "host:port".
func (c *Config) GetServerAddress() string {
	return fmt.Sprintf("%s:%d", c.SMTPHost, c.SMTPPort)
}

View on GitHub (pinned to 14d757ce1f)

Solutions

  1. Set FromEmail to a real mailbox you control at the sending domain (e.g., noreply@example.com).
  2. Check the config key that populates FromEmail matches what the loader expects.
  3. If the from address comes from a template/env var, assert it is non-empty at deploy time.

Example fix

// before
cfg := email.Config{SMTPHost: "smtp.example.com", SMTPPort: 587}

// after
cfg := email.Config{SMTPHost: "smtp.example.com", SMTPPort: 587, FromEmail: "noreply@example.com"}
Defensive patterns

Strategy: validation

Validate before calling

// Go
if !strings.Contains(cfg.FromEmail, "@") {
  return errors.New("from email missing or invalid")
}
if err := cfg.Validate(); err != nil {
  return err
}

Try / catch

if err := cfg.Validate(); err != nil {
  return errors.Wrap(err, "invalid SMTP config")
}

Prevention

When it happens

Trigger: Config constructed with FromEmail unset — the admin SMTP form's 'from' field left blank, or a config map missing the from key so the struct field stays "".

Common situations: Filling host/port but skipping the sender field in settings; renaming the config key (from vs fromEmail vs sender) so the loader never populates it; deploying with a templated config where the from variable expands to empty.

Related errors


AI-assisted analysis of usememos/memos@14d757ce1f (2026-08-15). Data as JSON: /api/errors/e10154cdcdaf22f5. Report an issue: GitHub.