plandex-ai/plandex · error · http

Error sending verification email:

Error message

Error sending verification email: 

What it means

This error is returned when email.SendVerificationEmail fails after the verification record was successfully created. The handler responds with HTTP 500 prefixed 'Error sending verification email: '. It wraps whatever SMTP/mail-provider error occurred, so the PIN exists in the DB but was never delivered to the user.

Source

Thrown at app/server/handlers/sessions.go:111

		// get sha256 hash of pin
		hashBytes := sha256.Sum256(pinBytes)
		pinHash := hex.EncodeToString(hashBytes[:])

		// create verification
		err = db.CreateEmailVerification(req.Email, req.UserId, pinHash)

		if err != nil {
			log.Printf("Error creating email verification: %v\n", err)
			http.Error(w, "Error creating email verification: "+err.Error(), http.StatusInternalServerError)
			return
		}

		err = email.SendVerificationEmail(req.Email, string(pinBytes))

		if err != nil {
			log.Printf("Error sending verification email: %v\n", err)
			http.Error(w, "Error sending verification email: "+err.Error(), http.StatusInternalServerError)
			return
		}

		res = shared.CreateEmailVerificationResponse{
			HasAccount: hasAccount,
		}
	} else {
		res = shared.CreateEmailVerificationResponse{
			HasAccount:  hasAccount,
			IsLocalMode: true,
		}
	}

	bytes, err := json.Marshal(res)

	if err != nil {
		log.Printf("Error marshalling response: %v\n", err)
		http.Error(w, "Error marshalling response: "+err.Error(), http.StatusInternalServerError)

View on GitHub (pinned to e2d772072e)

Solutions

  1. Read the wrapped error in the server log to see the exact SMTP/provider failure
  2. Verify SMTP environment variables (host, port, credentials, from-address) are set correctly
  3. Test outbound connectivity to the SMTP host/port from the server (telnet/nc)
  4. Confirm the mail provider account is active and the sender domain is verified
  5. Retry the verification request after fixing mail config

Example fix

// before: mail config only checked at send time
err = email.SendVerificationEmail(req.Email, string(pinBytes))
// after: fail fast at startup with a config check
func init() {
	for _, k := range []string{"SMTP_HOST", "SMTP_PORT", "SMTP_USER", "SMTP_PASS"} {
		if os.Getenv(k) == "" {
			log.Fatalf("missing required env var %s", k)
		}
	}
}
Defensive patterns

Strategy: fallback

Validate before calling

// preflight SMTP config before triggering verification
host := os.Getenv("SMTP_HOST")
port := os.Getenv("SMTP_PORT")
conn, err := net.DialTimeout("tcp", net.JoinHostPort(host, port), 5*time.Second)
if err != nil {
	return fmt.Errorf("SMTP unreachable: %w", err)
}
conn.Close()

Try / catch

// treat 500 on verification as a mail-config problem; surface it and offer resend
if resp.StatusCode == http.StatusInternalServerError {
	var msg string
	json.NewDecoder(resp.Body).Decode(&msg)
	if strings.HasPrefix(msg, "Error sending verification email") {
		return fmt.Errorf("mail delivery failed, check SMTP config; PIN not delivered")
	}
}

Prevention

When it happens

Trigger: POST to the email-verification endpoint (non-development, non-LOCAL_MODE environment) where the SMTP connection fails: bad SMTP host/port, auth rejection, TLS failure, provider rate limit, or timeout while sending to req.Email.

Common situations: Missing or wrong SMTP_* environment variables (host, port, user, password); firewall blocking outbound port 587/465; mail provider credentials expired or rotated; sending from an unverified domain causing provider rejection; no network access in a container.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/35273748e096cd93. Report an issue: GitHub.