From 5558c725a1ceb3d6cfe08805f2e0e45bda04542b Mon Sep 17 00:00:00 2001 From: Bram Prieshof Date: Tue, 14 Sep 2021 21:43:56 +0000 Subject: [PATCH] Add 'Proxmox-SMTPMail.sh' --- Proxmox-SMTPMail.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Proxmox-SMTPMail.sh diff --git a/Proxmox-SMTPMail.sh b/Proxmox-SMTPMail.sh new file mode 100644 index 0000000..a356667 --- /dev/null +++ b/Proxmox-SMTPMail.sh @@ -0,0 +1,34 @@ +#Proxmox Use SMTP to send mail +#Vars +MailFromName=$(hostname) +MailFormAddress=noreply@domain.com +MailFromServer=mail.provider.com +MailFromServerPort=465 +MailFromPasswd= +MailTo=administrator@domain.com + +#install dependencies +apt install libsasl2-modules -y + +#Generating Configs +echo "[$MailFromServer]:$MailFromServerPort $MailFormAddress.nl:$MailFromPasswd" > /etc/postfix/sasl_passwd +echo "/.+/ $MailFromName<$MailFormAddress>" > /etc/postfix/sender_canonical_maps +echo "/From:.*/ REPLACE From: $MailFromName<$MailFormAddress>" > /etc/postfix/header_check +sed -i '/relayhost/c\' /etc/postfix/main.cf +cat << EOF >> /etc/postfix/main.cf +#Custom PostfixSMTP config +relayhost = [$MailFromServer]:$MailFromServerPort +smtp_tls_wrappermode = yes +smtp_tls_security_level = encrypt +smtp_use_tls = yes +smtp_sasl_auth_enable = yes +smtp_sasl_security_options = +smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd +smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt +sender_canonical_classes = envelope_sender, header_sender +sender_canonical_maps = regexp:/etc/postfix/sender_canonical_maps +smtp_header_checks = regexp:/etc/postfix/header_check +EOF + +postmap /etc/postfix/sasl_passwd +systemctl restart postfix \ No newline at end of file