Arnt Gulbrandsen
About meAbout this blog

Installing and testing Postfix with unicode address support

By request: A step-to-step guide to installing/testing unicode addresses with Postfix. Perhaps overly detailed.

I'll use a new linux/ubuntu host here. As it happens, I use a 64-bit ubuntu 14.04 at Amazon.

The following commands prepare the host. This updates the host with the latest package database and packages, so that the later commands won't fail due to package inavailability or version conflicts.

apt-get update
apt-get dist-upgrade

This installs Postfix (without unicode support), the mutt mail reader for testing, and ICU (for being able to compile Postfix with unicode):

apt-get install postfix mutt libicu-dev

(Update: As of Postfix 3.0.0, this command installs Postfix including EAI support. If this command installed Postfix 3.0.0 or later, you do not need to patch and compile.)

The Postfix installer asks what kind of installation you want (screenshot), you must select internet site, then it asks about your domain name (screenshot), you add any domain name that you control. In this test I use eai-aws-test-1.gulbrandsen.priv.no as hostname and for the mail addresses.

You will also need some other packages to compile Postfix, which the build-dep command retrieves:

apt-get build-dep postfix

The commands above produce several hundred lines of output. At the end the result should look somewhat like screenshot 3.

Add the host name to the DNS. Check that you can access this domain from outside and access Postfix (screenshot from another host). Make an ordinary unix user, e.g. called test1 (screenshot), and switch to it:

su - test1

Start the Mutt program

mutt

and send mail (m, enter the address, subject, message body, then press control-x, enter, y). Quit mutt using the q command, then return to root using control-d and check the mail log (screenshot). The log in my screenshot shows clearly that Postfix attempted to send mail from and to the right addresses.

Reply to the test. On the test instance, run

cat /var/spool/mail/test1

which will show the reply in RFC822 format (screenshot). Now we know that the test can proceed. If something is broken, then that host is perhaps blocked from sending/receiving mail by a firewall.

Download the latest postfix. There are many download locations listed on the postfix site.

cd /tmp
wget ftp://ftp.cuhk.edu.hk/pub/packages/mail-server/postfix/experimental/postfix-2.12-20140716.tar.gz
tar zxf postfix-2.12-20140716.tar.gz
cd postfix-2.12-20140716

Now you have the postfix source unpacked (screenshot). and are ready to compile:

make makefiles; make upgrade

Again, you'll get several hundred lines of output (screenshot). Some of the lines that scrolled past ended with -l clauses (screenshot). Until at least September 2014, those have to contain -licuuc. If yours do not, stop here and find out why.

Enable unicode support by editing /etc/postfix/main.cf. You will have to add the line smtputf8_enable = yes, and you may need to set myorigin to the domain name you selected above if it has another value. Myorigin may even be specified twice. This screenshot shows a correct main.cf. Finally restart Postfix and test it:

postfix stop; postfix start
telnet localhost 25
ehlo x

You will receive a reply that includes SMTPUTF8 (screenshot). If not, something has failed. To finish this test, issue

quit

Now we know that Postfix claims to have SMTPUTF8 support. The next step is to send unicode mail from the test1 account. Mutt can do that, or this command:

su - test1
echo "To: jøran@blåbærsyltetøy.gulbrandsen.priv.no" | /usr/sbin/sendmail -t

About fifteen seconds later, a reply from jøran will land in /var/spool/mail/test1. You can watch the progress of the test by running

tail -f /var/log/mail.log

and then you can read the reply using

tail -20 /var/spool/mail/test1

The reply shows the message in RCC822/6532 format (screenshot of the last few commands). Notice that the ø letters are displayed correctly, both in jøran and in blåbærsyltetøy. Now we know that Postfix can send mail from an ordinary address to a unicode address on the internet, and receive a reply from a unicode address.

The next step involves a local unicode address as well. The ordinary linux tools are not happy about creating unicode logins, but here's how to rename test1 to testπ (the last letter is pi, ie. 3.14159…):

cd /etc
for a in passwd shadow group; do sed 's/test1/testπ/' < $a > a ; cat a > $a ; done

Change to that user, and send mail again, then test that it works:

su - testπ
echo "To: jøran@blåbærsyltetøy.gulbrandsen.priv.no" | /usr/sbin/sendmail -t
tail -f /var/spool/mail/testπ

After a few seconds the autoreply will arrive (screenshot) and you have tested that your Postfix can send mail both to and from unicode addresses. Congratulations.

Note that in early 2015, installing Postfix with unicode address support will become much simpler. Further, the version I used above is good enough to test with, but should not be used for production. The spool format will almost certainly change in the coming months.

Clueless in the cloud

What Amazon wrote:

We have noticed that one or more of your instances are running on a host degraded due to hardware failure. [...]

The host needs to undergo maintenance and will be taken down [...]

What Amazon might have written:

Thought you were clever, eh? Running that fancy Cassandra cluster? I bet you didn't expect your redundant copies on several Cassandra nodes to really be stored on the same crummy drive. […More…]