Use your Uberspace server as relay host for your local postfix instance

Here are the instructions for letting your home server send e-mails with help of your Uberspace account. This small guide is based on Ubuntu 13.04. I assume your Uberspace username is $USUSER and your Uberspace host is $USHOST.

Setup an additional mail address

See http://uberspace.de/dokuwiki/start:mail

 ssh $USUSER@$USHOST.uberspace.de
 vadduser local-server
 # enter a non-trivial password
 # the address "local-server" is now available via $USUSER-local-server@USHOST.uberspace.de

Setup postfix

apt-get install postfix libsasl2-modules bsd-mailx
# choose "Satellite System" for Postfix server type

Change /etc/postfix/main.cf

myhostname = mail.my-local.domain
mydestination = mail.my-local.domain, localhost
relayhost = $USHOST.uberspace.de:submission
smtp_sasl_auth_enable = true
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password

Add your newly created mail account

touch /etc/postfix/sasl_password
chmod 600 /etc/postfix/sasl_password
vim /etc/postfix/sasl_password
# add the following line
# $USHOST.uberspace.de:submission $USUSER-local-server@USHOST.uberspace.de:$PASSWORD
# :wq
service postfix restart

Send a test mail

mail -s "Test" mail@youraddress.de -- -f root@local-server.internal

tail -f /var/log/syslog should now contain something like

Aug 10 19:52:26 srv postfix/qmgr[11620]: 63EDB13C0F83: from=<root@local-server.internal>, size=309, nrcpt=1 (queue active)
Aug 10 19:52:26 srv postfix/smtp[11626]: connect to $USHOST.uberspace.de[2001:1a50:11:0:xx:yy:zz:x]:587: Network is unreachable
Aug 10 19:52:26 srv postfix/smtp[11626]: 63EDB13C0F83: to=<mail@youraddress.de>, relay=$USHOST.uberspace.de[95.143.xx.yy]:587, delay=0.64, delays=0.26/0.12/0.19/0.07, dsn=2.0.0, status=sent (250 ok 1376157144 qp 15391)
Aug 10 19:52:26 srv postfix/qmgr[11620]: 63EDB13C0F83: removed

The Network is unreachable is not important, because I don’t have IPv6 enabled.