@@ -50,6 +50,7 @@ choice=$(whiptail --title "$TITLE" --nocancel --menu \
50
50
" Please choose the mail provider that you want to use.
51
51
$MENU_GUIDE \n\n$RUN_LATER_GUIDE " " $WT_HEIGHT " " $WT_WIDTH " 4 \
52
52
" mail.de" " (German mail provider)" \
53
+ " SMTP2GO" " (https://www.smtp2go.com)" \
53
54
" Manual" " (Complete manual setup)" 3>&1 1>&2 2>&3 )
54
55
55
56
case " $choice " in
@@ -59,6 +60,13 @@ case "$choice" in
59
60
PROTOCOL=" SSL"
60
61
SMTP_PORT=" 465"
61
62
;;
63
+ " SMTP2GO" )
64
+ NEEDS_CREDENTIALS=1
65
+ SMTP2GO=1
66
+ MAIL_SERVER=" mail-eu.smtp2go.com"
67
+ PROTOCOL=" SSL"
68
+ SMTP_PORT=" 465"
69
+ ;;
62
70
# Manual setup will be handled a few lines below
63
71
" " )
64
72
msg_box " You haven't selected any option. Exiting!"
131
139
# Enter your SMTP username
132
140
if [ -n " $NEEDS_CREDENTIALS " ] || yesno_box_yes " Does $MAIL_SERVER require any credentials, like username and password?"
133
141
then
134
- MAIL_USERNAME=
$( input_box_flow " Please enter the SMTP username to your email provider.\nE.g. [email protected] " )
142
+ MAIL_USERNAME=
$( input_box_flow " Please enter the SMTP username to your email provider.\nE.g. [email protected] , or just the actual 'username'. " )
135
143
136
144
# Enter your mail user password
137
145
MAIL_PASSWORD=$( input_box_flow " Please enter the SMTP password to your email provider." )
@@ -198,6 +206,34 @@ account default : $MAIL_USERNAME
198
206
199
207
### DO NOT REMOVE THIS LINE (it's used in one of the functions in on the Nextcloud Server)
200
208
# recipient=$RECIPIENT
209
+ MSMTP_CONF
210
+ elif [ -n " $SMTP2GO " ]
211
+ then
212
+ # With AUTH (Username and Password)
213
+ cat << MSMTP_CONF > /etc/msmtprc
214
+ # Set default values for all following accounts.
215
+ defaults
216
+ auth on
217
+ aliases /etc/aliases
218
+ $MSMTP_ENCRYPTION1
219
+ $MSMTP_ENCRYPTION2
220
+
221
+ tls_trust_file /etc/ssl/certs/ca-certificates.crt
222
+ logfile /var/log/msmtp
223
+
224
+ # Account to send emails
225
+ account $MAIL_USERNAME
226
+ host $MAIL_SERVER
227
+ port $SMTP_PORT
228
+
229
+ user $MAIL_USERNAME
230
+ password $MAIL_PASSWORD
231
+
232
+ account default : $MAIL_USERNAME
233
+
234
+ ### DO NOT REMOVE THIS LINE (it's used in one of the functions in on the Nextcloud Server)
235
+ # recipient=$RECIPIENT
236
+
201
237
MSMTP_CONF
202
238
else
203
239
# With AUTH (Username and Password)
@@ -265,18 +301,25 @@ echo 'set sendmail="/usr/bin/msmtp -t"' > /etc/mail.rc
265
301
# Test mail
266
302
if ! echo -e " $TEST_MAIL " | mail -s " Test email from your NcVM" " $RECIPIENT " >> /var/log/msmtp 2>&1
267
303
then
268
- # Test another version
269
- echo ' set sendmail="/usr/bin/msmtp" ' > /etc/mail.rc
270
-
304
+ # Set from email address
305
+ sed -i " s|from .*|from [email protected] |g " /etc/
msmtprc
306
+
271
307
# Second try
272
308
if ! echo -e " $TEST_MAIL " | mail -s " Test email from your NcVM" " $RECIPIENT " >> /var/log/msmtp 2>&1
273
309
then
274
- # Fail message
275
- msg_box " It seems like something has failed.
310
+ # Test another version
311
+ echo ' set sendmail="/usr/bin/msmtp"' > /etc/mail.rc
312
+
313
+ # Third try
314
+ if ! echo -e " $TEST_MAIL " | mail -s " Test email from your NcVM" " $RECIPIENT " >> /var/log/msmtp 2>&1
315
+ then
316
+ # Fail message
317
+ msg_box " It seems like something has failed.
276
318
You can look at /var/log/msmtp for further logs.
277
319
Please run this script once more if you want to make another try or \
278
320
if you want to deinstall all newly installed packages."
279
- exit 1
321
+ exit 1
322
+ fi
280
323
fi
281
324
fi
282
325
@@ -285,7 +328,7 @@ msg_box "Congratulations, the test email was successfully sent!
285
328
Please check the inbox for $RECIPIENT . The test email should arrive soon."
286
329
287
330
# Only offer to use the same settings in Nextcloud if a password was chosen
288
- if [
" $MAIL_USERNAME " = " [email protected] " ]
331
+ if [
" $MAIL_USERNAME " = " [email protected] " ]
&& [ -z " $SMTP2GO " ]
289
332
then
290
333
exit
291
334
fi
316
359
# Authentification
317
360
nextcloud_occ config:system:set mail_smtpauthtype --value=" LOGIN"
318
361
nextcloud_occ config:system:set mail_smtpauth --type=integer --value=1
319
- nextcloud_occ config:system:set mail_from_address --value=" ${MAIL_USERNAME%%@* } "
320
- nextcloud_occ config:system:set mail_domain --value=" ${MAIL_USERNAME##*@ } "
362
+ if [ -n " $SMTP2GO " ]
363
+ then
364
+ nextcloud_occ config:system:set mail_from_address --value=" no-reply"
365
+ else
366
+ nextcloud_occ config:system:set mail_from_address --value=" ${MAIL_USERNAME%%@* } "
367
+ fi
368
+ if [ -n " $SMTP2GO " ]
369
+ then
370
+ nextcloud_occ config:system:set mail_domain --value=" nextcloudvm.com"
371
+ else
372
+ nextcloud_occ config:system:set mail_domain --value=" ${MAIL_USERNAME##*@ } "
373
+ fi
321
374
nextcloud_occ config:system:set mail_smtphost --value=" $MAIL_SERVER "
322
375
nextcloud_occ config:system:set mail_smtpport --value=" $SMTP_PORT "
323
376
nextcloud_occ config:system:set mail_smtpname --value=" $MAIL_USERNAME "
0 commit comments