0

My .procmailrc (really simple):

:0c
| $HOME/send_sms.sh "`formail -xFrom:`" "`formail -xSubject:`"

So, sender named "mail@domain.com" sends message with subject "Subject test ąść". The script "send_sms.sh" receives:

Sender: =?UTF-8?Q?mail@domain.com?= <mail@domain.com>

Subject: =?UTF-8?Q?Subject_test_=C4=85=C5=9B=C4=87?=

How should I modify my .procmailrc to get clear text? Or convert this in my script send_sms.sh ?

user1209216
  • 5,410
  • 7
  • 45
  • 95
  • I recommend you ask this on http://unix.stackexchance.com. – tshepang Jul 30 '12 at 23:05
  • What should it convert "Erdnüße" into? What about "Россия" or "مصر" or "日本"? – tripleee Jul 31 '12 at 05:38
  • Ok, maybe I was not clear. This is encoded part of mail header (int this example, utf8, but it also could be base64 or quoted-printable etc). And I need to decode this to readable form (like email clients do). Is this possible with bash, or maybe with formail itself? – user1209216 Jul 31 '12 at 16:06
  • UTF-8 is a character set, base64 and QP are encodings. Your examples have a character set of UTF-8 and an quoted-printable encoding. They could have any other character set as well. – tripleee Aug 01 '12 at 03:47

1 Answers1

1

http://metacpan.org/pod/Email::MIME::RFC2047::Decoder has a simple RFC2047 decoder in Perl. You should perhaps only decode strings which are in a character set you can support, but all your examples are in UTF-8, so if your script supports sending UTF-8 in SMS, you should be fine. For other character sets, perhaps you can convert into UTF-8 in a separate step before sending.

szabgab
  • 5,884
  • 9
  • 45
  • 61
tripleee
  • 139,311
  • 24
  • 207
  • 268