Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/vm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hansson <github@hanssonit.se>2020-10-02 23:51:19 +0300
committerGitHub <noreply@github.com>2020-10-02 23:51:19 +0300
commit248ee996c0f538477b75e16e33937ac27243c983 (patch)
tree518fb919b42a9fd400f3fa28d63a618f25fe93d3
parent17f52caa8a2efdb0a72e5a8c8f085c5240c979e4 (diff)
do the whole setup a little bit cleaner
-rw-r--r--addons/smtp-mail.sh96
1 files changed, 52 insertions, 44 deletions
diff --git a/addons/smtp-mail.sh b/addons/smtp-mail.sh
index dddaacec..58365e68 100644
--- a/addons/smtp-mail.sh
+++ b/addons/smtp-mail.sh
@@ -128,59 +128,67 @@ then
exit
fi
+# Add the encryption settings to the file as well
+if [ "$PROTOCOL" = "SSL" ]
+then
+ export MSMTP_ENCRYPTION1="tls on"
+ export MSMTP_ENCRYPTION2="tls_starttls off"
+elif [ "$PROTOCOL" = "STARTTLS" ]
+then
+ export MSMTP_ENCRYPTION1="tls off"
+ export MSMTP_ENCRYPTION2="tls_starttls on"
+elif [ "$PROTOCOL" = "NO-ENCRYPTION" ]
+then
+ export MSMTP_ENCRYPTION1="tls off"
+ export MSMTP_ENCRYPTION2="tls_starttls off"
+fi
+
# Check if auth should be set or not
if [ -z $MAIL_USERNAME ]
then
- MAIL_USERNAME="nextcloud_mail_server@yourserver.com"
-# Create the file
+ MAIL_USERNAME="nextcloud_mail_server@nextcloudvm.com"
+
+# Without AUTH (Username and Password)
cat << MSMTP_CONF > /etc/msmtprc
+# Set default values for all following accounts.
defaults
-port $SMTP_PORT
-tls_trust_file /etc/ssl/certs/ca-certificates.crt
-host $MAIL_SERVER
-from $MAIL_USERNAME
-auth off
-account default: $MAIL_USERNAME
-aliases /etc/aliases
-# recipient=$RECIPIENT
+auth off
+$MSMTP_ENCRYPTION1
+$MSMTP_ENCRYPTION2
+
+tls_trust_file /etc/ssl/certs/ca-certificates.crt
+logfile $VMLOGS/smtp_msmtp.log
+
+# Host
+account $MAIL_SERVER
+host $MAIL_SERVER
+port $SMTP_PORT
+from $MAIL_USERNAME
+
+account default : $MAIL_SERVER
MSMTP_CONF
else
-# Create the file
+
+# With AUTH (Username and Password)
cat << MSMTP_CONF > /etc/msmtprc
+# Set default values for all following accounts.
defaults
-port $SMTP_PORT
-tls_trust_file /etc/ssl/certs/ca-certificates.crt
-account $MAIL_USERNAME
-host $MAIL_SERVER
-from $MAIL_USERNAME
-auth on
-user $MAIL_USERNAME
-password $MAIL_PASSWORD
-account default: $MAIL_USERNAME
-aliases /etc/aliases
-# recipient=$RECIPIENT
-MSMTP_CONF
-unset MAIL_PASSWORD
-fi
-
-# Add the encryption settings to the file as well
-if [ "$PROTOCOL" = "SSL" ]
-then
-cat << MSMTP_CONF >> /etc/msmtprc
-tls on
-tls_starttls off
-MSMTP_CONF
-elif [ "$PROTOCOL" = "STARTTLS" ]
-then
-cat << MSMTP_CONF >> /etc/msmtprc
-tls off
-tls_starttls on
-MSMTP_CONF
-elif [ "$PROTOCOL" = "NO-ENCRYPTION" ]
-then
-cat << MSMTP_CONF >> /etc/msmtprc
-tls off
-tls_starttls off
+auth on
+$MSMTP_ENCRYPTION1
+$MSMTP_ENCRYPTION2
+
+tls_trust_file /etc/ssl/certs/ca-certificates.crt
+logfile $VMLOGS/smtp_msmtp.log
+
+# Host
+account $MAIL_SERVER
+host $MAIL_SERVER
+port $SMTP_PORT
+from $MAIL_USERNAME@$MAIL_SERVER
+user $MAIL_USERNAME@$MAIL_SERVER
+password $MAIL_PASSWORD
+
+account default : $MAIL_SERVER
MSMTP_CONF
fi