Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Ensure cloud emails use support reply-to
rcourtman5513781193be
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.mdindex 81d46ab1f3..c6d75e4c78 100644--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md@@ -480,6 +480,11 @@ or other self-hosted uncapped continuity plans.by the Cloud paid subsystem even when a narrower support subsystem alsoowns a deployment, security, or relay-specific file in the same packagetree.+ Control-plane transactional email may use a no-reply sender for delivery,+ but Resend delivery must set an explicit support reply path from+ `PULSE_EMAIL_REPLY_TO`, defaulting to `[email protected]`, so magic+ links, checkout handoffs, and other hosted-account messages remain+ directly replyable by customers.## Forbidden Pathsdiff --git a/internal/cloudcp/config.go b/internal/cloudcp/config.goindex 6eba3ae034..68e63bb73a 100644--- a/internal/cloudcp/config.go+++ b/internal/cloudcp/config.go@@ -62,6 +62,7 @@ type CPConfig struct {RequireEmailProvider boolResendAPIKey string // Resend API key (optional — if empty, emails are logged)EmailFrom string // Sender email address (e.g. "[email protected]")+ EmailReplyTo string // Support reply address for transactional email}// TenantsDir returns the directory where per-tenant data is stored.@@ -188,6 +189,7 @@ func LoadConfig() (*CPConfig, error) {RequireEmailProvider: envOrDefaultBool("CP_REQUIRE_EMAIL_PROVIDER", true),ResendAPIKey: strings.TrimSpace(os.Getenv("RESEND_API_KEY")),EmailFrom: envOrDefault("PULSE_EMAIL_FROM", "[email protected]"),+ EmailReplyTo: envOrDefault("PULSE_EMAIL_REPLY_TO", "[email protected]"),}if strings.TrimSpace(cfg.TrialActivationPrivateKey) != "" {publicKey, err := deriveTrialActivationPublicKey(cfg.TrialActivationPrivateKey)@@ -302,6 +304,9 @@ func (c *CPConfig) validate() error {if strings.TrimSpace(c.EmailFrom) == "" {return fmt.Errorf("PULSE_EMAIL_FROM is required when CP_REQUIRE_EMAIL_PROVIDER=true")}+ if strings.TrimSpace(c.EmailReplyTo) == "" {+ return fmt.Errorf("PULSE_EMAIL_REPLY_TO is required when CP_REQUIRE_EMAIL_PROVIDER=true")+ }}if strings.TrimSpace(c.StripeAPIKey) != "" && c.PublicCloudSignupEnabled && strings.TrimSpace(c.TrialSignupPriceID) == "" {return fmt.Errorf("CP_TRIAL_SIGNUP_PRICE_ID is required when STRIPE_API_KEY is configured")diff --git a/internal/cloudcp/config_test.go b/internal/cloudcp/config_test.goindex 7b11bc0949..7524e4d895 100644--- a/internal/cloudcp/config_test.go+++ b/internal/cloudcp/config_test.go@@ -73,6 +73,9 @@ func TestLoadConfig_AllRequired(t *testing.T) {if cfg.TenantLogMaxFile != 3 {t.Errorf("TenantLogMaxFile = %d, want 3", cfg.TenantLogMaxFile)}+ if cfg.EmailReplyTo != "[email protected]" {+ t.Errorf("EmailReplyTo = %q, want [email protected]", cfg.EmailReplyTo)+ }if cfg.StorageGuardrailsEnabled {t.Errorf("StorageGuardrailsEnabled = true in development, want false")}@@ -99,6 +102,7 @@ func TestLoadConfig_CustomValues(t *testing.T) {t.Setenv("CP_STORAGE_MAX_DOCKER_BUILD_CACHE", "1500MiB")t.Setenv("CP_PROOF_TENANT_MAX_AGE", "6h")t.Setenv("CP_PROOF_TENANT_MATCHERS", "proof,canary,proof")+ t.Setenv("PULSE_EMAIL_REPLY_TO", "[email protected]")cfg, err := LoadConfig()if err != nil {@@ -143,6 +147,9 @@ func TestLoadConfig_CustomValues(t *testing.T) {if got := strings.Join(cfg.ProofTenantMatchers, ","); got != "proof,canary" {t.Fatalf("ProofTenantMatchers = %q, want proof,canary", got)}+ if cfg.EmailReplyTo != "[email protected]" {+ t.Fatalf("EmailReplyTo = %q, want [email protected]", cfg.EmailReplyTo)+ }}func TestLoadConfig_EnablesStorageGuardrailsByDefaultInProduction(t *testing.T) {diff --git a/internal/cloudcp/email/sender.go b/internal/cloudcp/email/sender.goindex 32154c93cf..e8a5f3b87b 100644--- a/internal/cloudcp/email/sender.go+++ b/internal/cloudcp/email/sender.go@@ -7,6 +7,7 @@ import ("fmt""io""net/http"+ "strings""time")@@ -19,6 +20,7 @@ type Sender interface {type Message struct {From stringTo string+ ReplyTo stringSubject stringHTML stringText string@@ -26,14 +28,16 @@ type Message struct {// ResendSender sends emails via the Resend HTTP API.type ResendSender struct {- apiKey string- httpClient *http.Client+ apiKey string+ defaultReplyTo string+ httpClient *http.Client}// NewResendSender creates a Resend email sender.-func NewResendSender(apiKey string) *ResendSender {+func NewResendSender(apiKey, defaultReplyTo string) *ResendSender {return &ResendSender{- apiKey: apiKey,+ apiKey: apiKey,+ defaultReplyTo: defaultReplyTo,httpClient: &http.Client{Timeout: 10 * time.Second,},@@ -43,20 +47,30 @@ func NewResendSender(apiKey string) *ResendSender {type resendRequest struct {From string `json:"from"`To string `json:"to"`+ ReplyTo string `json:"reply_to,omitempty"`Subject string `json:"subject"`HTML string `json:"html,omitempty"`Text string `json:"text,omitempty"`}-// Send sends an email via the Resend API.-func (r *ResendSender) Send(ctx context.Context, msg Message) error {- payload := resendRequest{+func (r *ResendSender) requestForMessage(msg Message) resendRequest {+ replyTo := strings.TrimSpace(msg.ReplyTo)+ if replyTo == "" {+ replyTo = strings.TrimSpace(r.defaultReplyTo)+ }+ return resendRequest{From: msg.From,To: msg.To,+ ReplyTo: replyTo,Subject: msg.Subject,HTML: msg.HTML,Text: msg.Text,}+}++// Send sends an email via the Resend API.+func (r *ResendSender) Send(ctx context.Context, msg Message) error {+ payload := r.requestForMessage(msg)body, err := json.Marshal(payload)if err != nil {diff --git a/internal/cloudcp/email/sender_test.go b/internal/cloudcp/email/sender_test.goindex d7f553c924..f99e97435d 100644--- a/internal/cloudcp/email/sender_test.go+++ b/internal/cloudcp/email/sender_test.go@@ -2,6 +2,7 @@ package emailimport ("context"+ "encoding/json""testing")@@ -36,19 +37,65 @@ func TestLogSender_Send(t *testing.T) {}func TestResendSender_New(t *testing.T) {- sender := NewResendSender("re_test_key")+ sender := NewResendSender("re_test_key", "[email protected]")if sender == nil {t.Fatal("expected non-nil sender")}if sender.apiKey != "re_test_key" {t.Errorf("expected apiKey=re_test_key, got %s", sender.apiKey)}+ if sender.defaultReplyTo != "[email protected]" {+ t.Errorf("expected [email protected], got %s", sender.defaultReplyTo)+ }+}++func TestResendSender_RequestUsesDefaultReplyTo(t *testing.T) {+ sender := NewResendSender("re_test_key", " [email protected] ")++ payload := sender.requestForMessage(Message{+ From: "Pulse <[email protected]>",+ To: "[email protected]",+ Subject: "Sign in to Pulse",+ Text: "Open this link.",+ })++ body, err := json.Marshal(payload)+ if err != nil {+ t.Fatalf("Marshal: %v", err)+ }+ if !json.Valid(body) {+ t.Fatalf("payload is not valid JSON: %s", body)+ }+ var got map[string]string+ if err := json.Unmarshal(body, &got); err != nil {+ t.Fatalf("Unmarshal: %v", err)+ }+ if got["reply_to"] != "[email protected]" {+ t.Fatalf("reply_to = %q, want [email protected]", got["reply_to"])+ }+}++func TestResendSender_RequestPrefersMessageReplyTo(t *testing.T) {+ sender := NewResendSender("re_test_key", "[email protected]")++ payload := sender.requestForMessage(Message{+ From: "Pulse <[email protected]>",+ To: "[email protected]",+ ReplyTo: " [email protected] ",+ Subject: "Sign in to Pulse",+ Text: "Open this link.",+ })++ if payload.ReplyTo != "[email protected]" {+ t.Fatalf("ReplyTo = %q, want [email protected]", payload.ReplyTo)+ }}func TestMessage_Fields(t *testing.T) {msg := Message{From: "[email protected]",To: "[email protected]",+ ReplyTo: "[email protected]",Subject: "Hello",HTML: "<h1>Hello</h1>",Text: "Hello",@@ -60,4 +107,7 @@ func TestMessage_Fields(t *testing.T) {if msg.To != "[email protected]" {t.Errorf("unexpected To: %s", msg.To)}+ if msg.ReplyTo != "[email protected]" {+ t.Errorf("unexpected ReplyTo: %s", msg.ReplyTo)+ }}diff --git a/internal/cloudcp/server.go b/internal/cloudcp/server.goindex 6c41c90672..361e79161d 100644--- a/internal/cloudcp/server.go+++ b/internal/cloudcp/server.go@@ -80,7 +80,7 @@ func Run(ctx context.Context, version string) error {// Initialize email sendervar emailSender email.Senderif cfg.ResendAPIKey != "" {- emailSender = email.NewResendSender(cfg.ResendAPIKey)+ emailSender = email.NewResendSender(cfg.ResendAPIKey, cfg.EmailReplyTo)log.Info().Msg("Email sender configured (Resend)")} else if cfg.RequireEmailProvider {return fmt.Errorf("email provider required but RESEND_API_KEY is not configured")