2 # Copyright (C) 2016 Ian Kelling
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
19 # dunno why debian installed postfix with builddep emacs
20 # but I will just explicitly install it here since
21 # I use it for sending mail in emacs.
23 relayhost
="[mail.messagingengine.com]:587"
25 # ses initially suggests port 25, but I had problems connecting to that.
26 relayhost
="[email-smtp.us-west-2.amazonaws.com]:587"
29 s debconf-set-selections
<<EOF
30 postfix postfix/main_mailer_type select Satellite system
31 postfix postfix/mailname string $host
32 postfix postfix/relayhost string $relayhost
38 # Settings from reading the output when installing on debian,
39 # then seeing which were different in a default install on arch.
40 # I assume the same works for fedora.
42 mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
43 mailbox_size_limit = 0
44 relayhost = $relayhost
45 inet_interfaces = loopback-only
48 s systemctl
enable postfix
49 s systemctl start postfix
53 # note, previously, the rest of setup was done separately.
56 # based on,http://www.postfix.org/qmgr.8.html and my notes in gnus
57 # originally tried moving specific directories under /var/spool/postfix,
58 # but postfix didn't like that
59 if [[ ! -L /var
/spool
/postfix
]]; then
61 n
=/q
/postfix-
`distro-name``debian-archive`
63 echo "$0: warning: $n already exists before we do the link, removing it"
66 s
mv /var
/spool
/postfix
$n
67 s lnf
-T $n /var
/spool
/postfix
69 s journalctl
-n 20 |
cat # sudo as we may not have journal reading rights yet
73 # This also works instead of ~/.forward
74 # s sed -i --follow-symlinks '/^root/d' /etc/aliases ||:
75 #echo "root: $HOSTNAME@$SOME_DOMAIN" | s tee -a /etc/aliases
76 # this can't be a symlink and has permission restrictions
77 # it might work in /etc/aliases, but this seems more proper.
79 if s
grep amazonaws
/etc
/postfix
/sasl_passwd
&>/dev
/null
; then
80 forward
=$HOSTNAME@
$IMPERSONAL_DOMAIN
82 forward
=$HOSTNAME@
$PERSONAL_DOMAIN
84 e
$forward > ~
/.forward
85 e
$forward | s
tee /root
/.forward
87 # linode image has a root alias. completely useless, remove it.
88 sudo
sed -i '/^root:/d' /etc
/aliases
93 # if I wanted the from address to be renamed and sent to a different address,
94 # echo "sdx@localhost development@localhost" | sudo dd of=/etc/postfix/recipient_canonical
95 # sudo postmap hash:/etc/postfix/recipient_canonical
96 # sudo service postfix reload
99 # i'm assuming mail just won't work on systems without the sasl_passwd.
101 smtp_sasl_auth_enable = yes
102 smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
103 smtp_sasl_security_options = noanonymous
104 smtp_tls_security_level = secure
105 message_size_limit = 20480000
106 smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
107 inet_protocols = ipv4
109 # msg_size_limit: I ran into a log file not sending cuz of size. double from 10 to 20 meg limit
110 # inet_protocols: without this, postfix tries an ipv6 lookup then gives
111 # up and fails. snippet from syslog: type=AAAA: Host not found, try again
114 s postmap
hash:/etc
/postfix
/sasl_passwd
115 # offlineimap uses this too, it is much easier to use one location than to
116 # condition it's config and postfix's config
118 fedora
) s lnf
-T ca-certificates.crt
/etc
/ssl
/ca-bundle.trust.crt
;;
122 s service postfix reload