Skip to content

Commit 5ff6739

Browse files
committed
chore: detect mailer
1 parent 04fd4f5 commit 5ff6739

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

script/diagnose_appflowy.sh

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,102 @@ check_admin_credentials() {
13061306
return 0
13071307
}
13081308

1309+
check_smtp_configuration() {
1310+
print_verbose "Checking SMTP configuration for emails..."
1311+
1312+
if ! load_env_vars; then
1313+
return 1
1314+
fi
1315+
1316+
local gotrue_smtp_host="${GOTRUE_SMTP_HOST}"
1317+
local gotrue_smtp_port="${GOTRUE_SMTP_PORT}"
1318+
local gotrue_smtp_user="${GOTRUE_SMTP_USER}"
1319+
1320+
local appflowy_smtp_host="${APPFLOWY_MAILER_SMTP_HOST}"
1321+
local appflowy_smtp_port="${APPFLOWY_MAILER_SMTP_PORT}"
1322+
local appflowy_smtp_username="${APPFLOWY_MAILER_SMTP_USERNAME}"
1323+
local appflowy_smtp_email="${APPFLOWY_MAILER_SMTP_EMAIL}"
1324+
1325+
local has_gotrue_smtp=false
1326+
local has_appflowy_smtp=false
1327+
local has_issues=false
1328+
1329+
# Check if GOTRUE SMTP is configured
1330+
if [[ -n "$gotrue_smtp_host" && -n "$gotrue_smtp_port" ]]; then
1331+
has_gotrue_smtp=true
1332+
print_success "GOTRUE SMTP configured: $gotrue_smtp_host:$gotrue_smtp_port"
1333+
print_verbose " Used for: Authentication emails (signup, password reset, magic links)"
1334+
fi
1335+
1336+
# Check if APPFLOWY MAILER SMTP is configured
1337+
if [[ -n "$appflowy_smtp_host" && -n "$appflowy_smtp_port" ]]; then
1338+
has_appflowy_smtp=true
1339+
print_success "APPFLOWY_MAILER SMTP configured: $appflowy_smtp_host:$appflowy_smtp_port"
1340+
print_verbose " Used for: Workspace invitations, sharing notifications"
1341+
fi
1342+
1343+
# Critical check: GOTRUE configured but APPFLOWY not configured
1344+
if [[ "$has_gotrue_smtp" == "true" && "$has_appflowy_smtp" == "false" ]]; then
1345+
print_error "SMTP Configuration Incomplete (CRITICAL for workspace sharing)"
1346+
print_error " Issue: GOTRUE_SMTP is configured but APPFLOWY_MAILER_SMTP is not"
1347+
print_error " Impact: Users CANNOT share workspaces or send invitations"
1348+
print_error " GOTRUE_SMTP is only for auth emails (signup, password reset)"
1349+
print_error " APPFLOWY_MAILER_SMTP is required for workspace invitations"
1350+
print_error ""
1351+
print_error " Fix: Add these to .env file:"
1352+
print_error " APPFLOWY_MAILER_SMTP_HOST=$gotrue_smtp_host"
1353+
print_error " APPFLOWY_MAILER_SMTP_PORT=$gotrue_smtp_port"
1354+
if [[ -n "$gotrue_smtp_user" ]]; then
1355+
print_error " APPFLOWY_MAILER_SMTP_USERNAME=$gotrue_smtp_user"
1356+
print_error " APPFLOWY_MAILER_SMTP_EMAIL=$gotrue_smtp_user"
1357+
fi
1358+
print_error " APPFLOWY_MAILER_SMTP_PASSWORD=<your_smtp_password>"
1359+
print_error " APPFLOWY_MAILER_SMTP_TLS_KIND=wrapper # or 'required'"
1360+
print_error ""
1361+
print_error " Then restart: docker compose restart appflowy_cloud"
1362+
has_issues=true
1363+
fi
1364+
1365+
# Warning: Neither configured
1366+
if [[ "$has_gotrue_smtp" == "false" && "$has_appflowy_smtp" == "false" ]]; then
1367+
print_info "SMTP: Not configured (email features disabled)"
1368+
print_info " Without SMTP, the following features won't work:"
1369+
print_info " - Workspace invitations (users cannot share workspaces)"
1370+
print_info " - Email notifications"
1371+
print_info " - Password reset emails (if GOTRUE_MAILER_AUTOCONFIRM=false)"
1372+
print_info " To enable email features, configure both:"
1373+
print_info " - GOTRUE_SMTP_* (for authentication emails)"
1374+
print_info " - APPFLOWY_MAILER_SMTP_* (for workspace invitations)"
1375+
fi
1376+
1377+
# Success: Both configured
1378+
if [[ "$has_gotrue_smtp" == "true" && "$has_appflowy_smtp" == "true" ]]; then
1379+
print_success "SMTP: Fully configured for all email features"
1380+
1381+
# Check if credentials are set
1382+
if [[ -z "$appflowy_smtp_username" || -z "$appflowy_smtp_email" ]]; then
1383+
print_warning "APPFLOWY_MAILER_SMTP_USERNAME or APPFLOWY_MAILER_SMTP_EMAIL not set"
1384+
fi
1385+
fi
1386+
1387+
# Additional validation: Check TLS kind
1388+
local tls_kind="${APPFLOWY_MAILER_SMTP_TLS_KIND}"
1389+
if [[ "$has_appflowy_smtp" == "true" ]]; then
1390+
if [[ -z "$tls_kind" ]]; then
1391+
print_warning "APPFLOWY_MAILER_SMTP_TLS_KIND not set (defaults may not work)"
1392+
print_warning " Recommended values: 'wrapper' (port 465), 'required' (port 587)"
1393+
else
1394+
print_verbose "TLS Kind: $tls_kind"
1395+
fi
1396+
fi
1397+
1398+
if [[ "$has_issues" == "true" ]]; then
1399+
return 1
1400+
fi
1401+
1402+
return 0
1403+
}
1404+
13091405
# ==================== FUNCTIONAL TESTS ====================
13101406

13111407
check_minio_storage() {
@@ -1862,6 +1958,19 @@ generate_recommendations() {
18621958
echo ""
18631959
has_critical=true
18641960
fi
1961+
1962+
if echo "$issue" | grep -qi "SMTP Configuration Incomplete"; then
1963+
echo "Priority 1 (CRITICAL): SMTP Configuration for Workspace Sharing"
1964+
echo " - Issue: GOTRUE_SMTP configured but APPFLOWY_MAILER_SMTP is missing"
1965+
echo " - Impact: Users CANNOT share workspaces or send invitations"
1966+
echo " - Common mistake: Configuring only GOTRUE_SMTP (for auth) but forgetting APPFLOWY_MAILER_SMTP (for invitations)"
1967+
echo " - Fix: Both SMTP configurations are required:"
1968+
echo " - GOTRUE_SMTP_* for authentication emails (signup, password reset)"
1969+
echo " - APPFLOWY_MAILER_SMTP_* for workspace invitations and sharing"
1970+
echo " - Add to .env and restart: docker compose restart appflowy_cloud"
1971+
echo ""
1972+
has_critical=true
1973+
fi
18651974
done
18661975

18671976
# Check for warnings
@@ -1933,6 +2042,7 @@ main() {
19332042
check_scheme_consistency
19342043
check_gotrue_configuration
19352044
check_admin_credentials
2045+
check_smtp_configuration
19362046
check_nginx_websocket_config
19372047
check_production_https_websocket
19382048
check_ssl_certificate

0 commit comments

Comments
 (0)