Skip to content

Commit d4536dd

Browse files
committed
fix #2765
1 parent 2d36913 commit d4536dd

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

addons/smtp-mail.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,15 @@ fi
139139
# Enter your SMTP username
140140
if [ -n "$NEEDS_CREDENTIALS" ] || yesno_box_yes "Does $MAIL_SERVER require any credentials, like username and password?"
141141
then
142-
MAIL_USERNAME=$(input_box_flow "Please enter the SMTP username to your email provider.\nE.g. [email protected], or just the actual 'username'.")
142+
if [ "$choice" = "mail.de" ]
143+
then
144+
# For mail.de, ask for email address first
145+
MAIL_FROM=$(input_box_flow "Please enter your email address for mail.de.\nE.g. [email protected]")
146+
# Then ask for username (which may differ from email)
147+
MAIL_USERNAME=$(input_box_flow "Please enter your username for mail.de.\nThis is the username you use to log in (may differ from your email address).")
148+
else
149+
MAIL_USERNAME=$(input_box_flow "Please enter the SMTP username to your email provider.\nE.g. [email protected], or just the actual 'username'.")
150+
fi
143151

144152
# Enter your mail user password
145153
MAIL_PASSWORD=$(input_box_flow "Please enter the SMTP password to your email provider.")
@@ -166,6 +174,7 @@ SMTP Relay URL=$MAIL_SERVER
166174
Encryption=$PROTOCOL
167175
SMTP Port=$SMTP_PORT
168176
SMTP Username=$MAIL_USERNAME
177+
$(if [ -n "$MAIL_FROM" ]; then echo "From Email Address=$MAIL_FROM"; fi)
169178
SMTP Password=$MAIL_PASSWORD
170179
Recipient=$RECIPIENT
171180
Self-signed TLS/SSL certificate=$SELF_SIGNED_CERT"
@@ -265,7 +274,7 @@ logfile /var/log/msmtp
265274
account $MAIL_USERNAME
266275
host $MAIL_SERVER
267276
port $SMTP_PORT
268-
from $MAIL_USERNAME
277+
from ${MAIL_FROM:-$MAIL_USERNAME}
269278
user $MAIL_USERNAME
270279
password $MAIL_PASSWORD
271280
@@ -376,13 +385,17 @@ if [ -n "$SMTP2GO" ]
376385
then
377386
nextcloud_occ config:system:set mail_from_address --value="no-reply"
378387
else
379-
nextcloud_occ config:system:set mail_from_address --value="${MAIL_USERNAME%%@*}"
388+
# Use MAIL_FROM if set (for mail.de with separate username), otherwise use MAIL_USERNAME
389+
MAIL_ADDRESS="${MAIL_FROM:-$MAIL_USERNAME}"
390+
nextcloud_occ config:system:set mail_from_address --value="${MAIL_ADDRESS%%@*}"
380391
fi
381392
if [ -n "$SMTP2GO" ]
382393
then
383394
nextcloud_occ config:system:set mail_domain --value="nextcloudvm.com"
384395
else
385-
nextcloud_occ config:system:set mail_domain --value="${MAIL_USERNAME##*@}"
396+
# Use MAIL_FROM if set (for mail.de with separate username), otherwise use MAIL_USERNAME
397+
MAIL_ADDRESS="${MAIL_FROM:-$MAIL_USERNAME}"
398+
nextcloud_occ config:system:set mail_domain --value="${MAIL_ADDRESS##*@}"
386399
fi
387400
nextcloud_occ config:system:set mail_smtphost --value="$MAIL_SERVER"
388401
nextcloud_occ config:system:set mail_smtpport --value="$SMTP_PORT"

0 commit comments

Comments
 (0)