Fix SMTP username/password defaults to only apply when BOTH are empty
Fixed issue where read -sp (silent prompt) with default
${SMTP_USER:-$IMAP_USER} would use default even when user
provided a value.
Now only uses IMAP defaults when BOTH SMTP username
AND password are empty (user skipped both prompts).
This preserves user's explicit values while correctly
handling the case where user presses Enter on optional
SMTP prompts.
This commit is contained in:
1 parent
e49020b193
commit
2a38265ead
1 file changed
+13
-1
@@ -58,9 +58,21 @@ read -p "SMTP Port (default: 465 for SSL, 587 for STARTTLS): " SMTP_PORT
|
|||||||
SMTP_PORT=${SMTP_PORT:-465}
|
SMTP_PORT=${SMTP_PORT:-465}
|
||||||
|
|
||||||
read -p "SMTP Username (default: same as IMAP): " SMTP_USER
|
read -p "SMTP Username (default: same as IMAP): " SMTP_USER
|
||||||
SMTP_USER=${SMTP_USER:-$IMAP_USER}
|
read -sp SMTP_USER
|
||||||
|
if [ -z "$SMTP_USER" ] && [ -z "$SMTP_PASS" ]; then
|
||||||
|
# Only use IMAP defaults if BOTH SMTP username and password are empty
|
||||||
|
SMTP_USER=${SMTP_USER:-$IMAP_USER}
|
||||||
|
else
|
||||||
|
SMTP_USER=${SMTP_USER}
|
||||||
|
fi
|
||||||
|
|
||||||
read -sp "SMTP Password (default: same as IMAP): " SMTP_PASS
|
read -sp "SMTP Password (default: same as IMAP): " SMTP_PASS
|
||||||
|
if [ -z "$SMTP_USER" ] && [ -z "$SMTP_PASS" ]; then
|
||||||
|
# Only use IMAP defaults if BOTH SMTP username and password are empty
|
||||||
|
SMTP_PASS=${SMTP_PASS:-$IMAP_PASS}
|
||||||
|
else
|
||||||
|
SMTP_PASS=${SMTP_PASS}
|
||||||
|
fi
|
||||||
if [ -z "$SMTP_PASS" ]; then
|
if [ -z "$SMTP_PASS" ]; then
|
||||||
SMTP_PASS="$IMAP_PASS"
|
SMTP_PASS="$IMAP_PASS"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in new issue
Block a user