Skip to content


Exim4, PostgreSQL and: invalid byte sequence for encoding UTF8

Today I got mailed by cron, that there is something in Exim’s paniclog. After investigating I found a line like this:

2009-03-25 09:40:24 failed to expand "${lookup pgsql{SELECT [...]}}" while checking a list: lookup of "SELECT [...]" gave DEFER: PGSQL: query failed: ERROR:  invalid byte sequence for encoding "UTF8": 0xc06e

No wonder… There is a local_user check in place in RCPT ACL and Exim checks username in DB table. The $local_part in the SQL query is taken directly from RCPT TO command without checking its encoding validity. You may expect anything on the wire though.

You need to add a check for UTF-8 validity of the $local_part. Exim does not have it built-in, but there is an easy way to code it manually.

Create an /usr/local/bin/isutf8 file:

#!/bin/bash
exec echo "$1" | /usr/bin/iconv -f UTF-8 -t UTF-8 >/dev/null 2>&1

Make it executable and add this rule to RCPT ACL just before the local_parts check:

deny
    message = address is invalid UTF-8
    condition = ${run{/usr/local/bin/isutf8 \"$local_part\"}{no}{yes}}

Restart Exim and you’re done.


Posted in HowTo.

Tagged with , , , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

You must be logged in to post a comment.