Nethence NEWDOC OLDDOC Lab Webmail Your IP BBDock  

setting up outgoing emails

on a host or on a docker container

in short

checks

if the smarthost does not resolve for some reason, hardcode it into /etc/hosts.

aliases

configure root mail alias to receive crontab and yum upgrade availability notifications,

cd /etc/
cp -pi aliases alises.dist
vi aliases

postmaster: root
root:       user@example.com
wheeleduser:    root
appuser:    root
cronuser:   root

newaliases

MTA & local listening daemon

configure outgoing smtp (smarthost),

cd /etc/postfix/
cp -i main.cf main.cf.dist
vi main.cf

relayhost = SMARTHOST

service rsyslog restart
#container: rsyslogd

service postfix stop
pkill master
service postfix start
#container: postfix reload

also if running Ubuntu you might need to allow Postfix to resolve hosts from its chroot land,

cd /var/spool/postfix/etc/
cp -pf /etc/resolv.conf /etc/hosts /etc/services ./

mkdir -p /var/spool/postfix/lib/x86_64-linux-gnu/
cd /var/spool/postfix/lib/x86_64-linux-gnu/
cp -vl /lib/x86_64-linux-gnu/libnss_* ./
ls -alhF

check check check

now check that you receive that email,

date | mailx -s test_from_`hostname --long` root
mailq
pmailq

and watch the logs,

#centos,
tail -20 /var/log/maillog
#ubuntu,
#tail -20 /var/log/mail.log