RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Fix: check SMTP config before send email (#19929)
Lynn8689f038c546
diff --git a/internal/handler/tenant.go b/internal/handler/tenant.goindex da39892098..f6a6ae4775 100644--- a/internal/handler/tenant.go+++ b/internal/handler/tenant.go@@ -30,6 +30,8 @@ import ("ragflow/internal/common""ragflow/internal/service"dataset "ragflow/internal/service/dataset"++ "go.uber.org/zap")// TenantHandler tenant handler@@ -352,17 +354,23 @@ func (h *TenantHandler) ListTenantMembers(c *gin.Context) {common.SuccessWithData(c, members, "success")}-func sendTenantInviteEmail(toEmail, recipientEmail, tenantID, inviter string) error {+// tenantSMTPConfig returns the SMTP settings together with a flag telling+// whether they are usable. SMTP is optional: when it is not configured the+// caller must skip sending instead of failing the request.+func tenantSMTPConfig() (common.SMTPConfig, bool) {config := server.GetConfig()if config == nil {- return fmt.Errorf("server config is not initialized")+ return common.SMTPConfig{}, false}smtpCfg := config.GetSMTPConfig()- if smtpCfg.MailServer == "" || smtpCfg.MailPort == 0 {- return fmt.Errorf("SMTP config is incomplete")+ if smtpCfg.MailServer == "" || smtpCfg.MailPort == 0 || smtpCfg.MailFromAddress == "" {+ return common.SMTPConfig{}, false}+ return smtpCfg, true+}+func sendTenantInviteEmail(smtpCfg common.SMTPConfig, toEmail, recipientEmail, tenantID, inviter string) error {from := mail.Address{Name: smtpCfg.MailFromName,Address: smtpCfg.MailFromAddress,@@ -511,9 +519,15 @@ func (h *TenantHandler) AddTenantMember(c *gin.Context) {if inviter == "" {inviter = user.Email}- if err = sendTenantInviteEmail(req.Email, req.Email, tenantID, inviter); err != nil {- common.ResponseWithCodeData(c, common.CodeServerError, nil, err.Error())- return+ // The member is already invited at this point; a missing or broken SMTP+ // setup must not turn the whole invitation into a failure.+ if smtpCfg, ok := tenantSMTPConfig(); ok {+ if err = sendTenantInviteEmail(smtpCfg, req.Email, req.Email, tenantID, inviter); err != nil {+ common.Warn("failed to send tenant invite email",+ zap.String("tenant_id", tenantID),+ zap.String("email", req.Email),+ zap.Error(err))+ }}common.SuccessWithData(c, resp, "success")