Add 'Proxmox-SMTPMail.sh'
This commit is contained in:
34
Proxmox-SMTPMail.sh
Normal file
34
Proxmox-SMTPMail.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
#Proxmox Use SMTP to send mail
|
||||
#Vars
|
||||
MailFromName=$(hostname)
|
||||
MailFormAddress=noreply@domain.com
|
||||
MailFromServer=mail.provider.com
|
||||
MailFromServerPort=465
|
||||
MailFromPasswd=<MailBoxPassword>
|
||||
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
|
||||
Reference in New Issue
Block a user