in reply to UTF8 and Postgresql

Grepping through the source of Email::Folder doesn't find a single occurrence of "utf"... so I suspect the module is not UTF-8 aware. In this case your mail data is at the moment Perl-internally probably not handled as unicode, but as a mere octet/byte-string. Or are you decoding it yourself manually, already? If not, you could try to pass the data through Encode::decode to sanitize it and convert it to unicode text, which the DBD::Pg driver will hopefully then handle correctly:

use Encode; ... my $utf8 = Encode::decode("UTF-8", $mail);

The optional third 'CHECK' argument to decode() defaults to Encode::FB_DEFAULT, which should be what you want, i.e. it replaces invalid UTF-8 sequences with the (valid) codepoint FFFD (REPLACEMENT CHARACTER) — also see Handling Malformed Data, so Postgresql should no longer have any reason to complain...