in reply to UTF8 and Postgresql

Some emails seem to be in a non-ASCII, non-UTF8 encoding, e.g. ISO-8859-1. You could try to detect this and convert them to UTF8 before you pass them to the DB. Search for 'Unicode' at CPAN and look which of the modules there are best for you.

If you just like to remove all non-ASCII characters, you could use tr/\200-\377//d.