Support Forum

Problem with foreign characters in post by email

GT Graham Tappenden
Graham Tappenden
Member

I have activated the post by email plug-in on my forum www.brunnentreff.de/forum which runs in German and uses the German language files for the core, theme, plug-ins etc.

The post by email works well, except that it cannot handle the German character set.  We use the following characters: ä ö ü Ä Ö Ü ß

If I post an e-mail with these in from GMail, they get converted into =E4 =F6 =FC =C4 =D6 =DC =DF

Can a parse be added to the plug-in to convert them back again?

22 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

Firstly my apologies for it taking so long to respond. You posted in the middle of a hosting move and for some reason it always takes longer for my dns changes to resolve so I only got full and stable access back this morning.

Would you be willing to send me an email using the same email client you used for the above and incorporating the same character set so that can scrutinise the raw message and see what it is we are missing?

If so then please send that to support at simple-press dot com and I will get into it. We clearly need to sort that.

Additional: Are you allowing attachments in your post by email posts? If not and you are willing to perform a few tests for me – and willing to make a small code change! – then let me know.

GT Graham Tappenden
Graham Tappenden
Member

I’ve just sent the e-mail with the characters in, just the same as I sent to the form except for the recipient.

I am allowing attachments, at least jpegs, which works very nicely and scales them to the max. size.

YS Yellow Swordfish
Yellow Swordfish
Member

Would you be willing to make a small code addition to test a possible fix?

GT Graham Tappenden
Graham Tappenden
Member

Sure, I’ll do it overnight when the forum is quiet and backed up.

YS Yellow Swordfish
Yellow Swordfish
Member

That ‘s great – thanks.

OK – the file needed is in your forum-plugins folder /post-by-email/library/sp-email-post-imap.php

The function we need to make a change to is called sp_process_inbox_imap() but we actual;ly need to add a new line at about line 205. Look for this line of code:

if(empty($content) && $maybeNew) $content = $rawContent;

and on the line after that add:

$content = trim(utf8_encode(quoted_printable_decode($content)));

This change will pnly effect new email processing of course. It is also a test/temporary adjustment. If this works for you then we will get a proper fix in place for the next plugin update.

Thanks for the assistance.

GT Graham Tappenden
Graham Tappenden
Member

I’m afraid it didn’t work, the e-mail content got converted to this:

5CD2IPwgxCDWINwg3w0K

YS Yellow Swordfish
Yellow Swordfish
Member

Ha!
What is the charset of your WP site and – more importantly – your WP database please. That code fix assumed utf8…

GT Graham Tappenden
Graham Tappenden
Member

Yellow Swordfish said
What is the charset of your WP site and – more importantly – your WP database please. That code fix assumed utf8…

Both are set to utf8, with the database collation set to utf8_general_ci.

 

The characters work fine in the other direction as well, ie. e-mail subscriptions to the topics.

GT Graham Tappenden
Graham Tappenden
Member

However something is strange about the fix.  The file only has 175 lines in it and the line to search for is at line 44, so nowhere near 205.

This is the version information in it:

/*
Simple:Press
Post by Email - Processing using IMAP
$LastChangedDate: 2012-04-24 15:14:20 +0100 (Tue, 24 Apr 2012) $
$Rev: 8448 $
*/

Is that the right file and the right version?

MP Mr Papa
Mr Papa
Member

hmmmm… I see Andy’s references in the working plugin…  but I dont see them (line number wise) in the current released plugin…. that bothers me since both say same version…  Andy must have some changes forth coming and not updated the release number…

but yes, in the current released version, the line would be 45…

GT Graham Tappenden
Graham Tappenden
Member

OK, this is really strange.

After you confirmed line 45 to me, I decided to try it again but to use a different text in the e-mail.  I have changed nothing else in the configuration except adding that line.

 

If I send a “real” text in the e-mail, ie. a German text containing those characters, it now works.

If I send the characters on their own, like in the sample I sent to the support e-mail address, I get the scrambled mess I was getting yesterday.

I’ve no idea why, but at least if the users post I presume that they will be using normal texts and it will work.

MP Mr Papa
Mr Papa
Member

sounds like progress…  and yes, there is a difference…  all the content in a post goes through a bunch of filters and other actions to prepare it… so when its emailed, its likely been prepped to work…

not sure I can explain the emailing direct except for perhaps the encoding in the client not set up to handle it?

YS Yellow Swordfish
Yellow Swordfish
Member

Graham Tappenden said
OK, this is really strange.

Er… yes.

I think what I need to do is consolidate that code change properly so we can test it out here fully before we release an update. But I think that is going the right way and am sorry it was missed initially…

GT Graham Tappenden
Graham Tappenden
Member

I’m afraid I have another problem with the same function now.  If I send an e-mail with a photo attached but without any other text in the message body, it doesn’t get posted and the log shows an error that roughly translates as “checking post content failed”.

I pretty certain this worked before I made the change for the foreign characters, and if I add a line of text to the message it still works as well.