-
Notifications
You must be signed in to change notification settings - Fork 7
/
install.postfix.sh
37 lines (30 loc) · 1002 Bytes
/
install.postfix.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# ensure that this script is run by root
if [ $(id -u) -ne 0 ]; then
sudo $0
exit
fi
# pre-configure
debconf-set-selections <<\EOF
postfix postfix/mailname string $(hostname)
postfix postfix/main_mailer_type select Internet Site
EOF
# install
apt-get install -y postfix
# post-configure
cp /etc/postfix/main.cf /etc/postfix/main.cf.$(date -I)
postconf -e 'myhostname = example.com'
postconf -e 'smtp_sasl_security_options = noanonymous'
postconf -e 'smtp_sasl_auth_enable = yes'
postconf -e 'message_size_limit = 0'
# configure smtp
echo 'smtp.gmail.com [email protected]:password' > /etc/postfix/sasl_password
postmap /etc/postfix/sasl_password
postconf -e 'relayhost = smtp.gmail.com'
postconf -e 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_password'
# configure user mapping
echo "[email protected] [email protected]" >> /etc/postfix/generic
postmap /etc/postfix/generic
postconf -e 'smtp_generic_maps = hash:/etc/postfix/generic'
# restart
/etc/init.d/postfix restart