Commit e3841fa2 authored by Dashamir Hoxha's avatar Dashamir Hoxha

Fix msmtp script

parent 32336936
......@@ -2,6 +2,13 @@
source /host/settings.sh
[[ -z $SMTP_SERVER ]] && [[ -z $GMAIL_ADDRESS ]] && exit 0
# make sure that the right packages are installed
apt purge --yes mailutils mailutils-common
apt autoremove --yes
apt install --yes msmtp msmtp-mta bsd-mailx
if [[ -n $SMTP_SERVER ]]; then
cat <<-_EOF > /etc/msmtprc
host $SMTP_SERVER
......@@ -11,6 +18,7 @@ auto_from on
aliases /etc/aliases.msmtp
syslog LOG_MAIL
_EOF
forward_address=${ADMIN_EMAIL:-${FORWARD_ADDRESS:-admin@$SMTP_DOMAIN}}
elif [[ -n $GMAIL_ADDRESS ]]; then
cat <<-_EOF > /etc/msmtprc
host smtp.gmail.com
......@@ -26,12 +34,10 @@ auth on
user $GMAIL_ADDRESS
password $GMAIL_PASSWD
_EOF
else
exit
forward_address=${ADMIN_EMAIL:-${FORWARD_ADDRESS:-$GMAIL_ADDRESS}}
fi
# forward all local emails
forward_address=${ADMIN_EMAIL:-${FORWARD_ADDRESS:-$GMAIL_ADDRESS}}
cat <<-_EOF > /etc/aliases.msmtp
default: $forward_address
_EOF
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment