Android Question pop (Net Library) problem with encoding?

harris_offease

Member
Licensed User
Longtime User
I am using Net Library, and the MailParser Module, to receive emails at my application.
Everything seems to be fine when using English Letters in body, however when there are Greek Letters, the message seems to disappear.. (m.body = empty)

I have tried both from Google email, and Hotmail but the result is the same..
Does pop support UTF-8?

From the Basic4Android Log i found out that with Google email, the Content-Type charset is UTF-8 (the body however seems to be encoded64),

(Email received by google email, includes the greek message)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: base64
PGRpdiBkaXI9Imx0ciI+z4DOsc65zr7OtSA8YnI+PC9kaXY+DQo=



(Email received by hotmail email, includes the greek message)
and when using Hotmail, it is "iso-8859-7" and appears as
<body class=3D'hmmessage'><div dir=3D'ltr'>=E5=EB=EB=E1=E4=E1!<br> =
 

harris_offease

Member
Licensed User
Longtime User
Just in case, it may help , First One is with english chars an email, while the second is with greek... (used google email for both cases)

(ENGLISH:)


Delivered-To: [email protected]

Received: by 10.112.253.37 with SMTP id zx5csp97928lbc;

Mon, 2 Jun 2014 04:55:53 -0700 (PDT)

X-Received: by 10.236.82.104 with SMTP id n68mr3005757yhe.142.1401710123749;

Mon, 02 Jun 2014 04:55:23 -0700 (PDT)

Return-Path: <[email protected]>

Received: from mail-yh0-x241.google.com (mail-yh0-x241.google.com [2607:f8b0:4002:c01::241])

by mx.google.com with ESMTPS id x58si22808523yhg.212.2014.06.02.04.55.23

for <[email protected]>

(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);

Mon, 02 Jun 2014 04:55:23 -0700 (PDT)

Received-SPF: pass (google.com: domain of [email protected] designates 2607:f8b0:4002:c01::241 as permitted sender) client-ip=2607:f8b0:4002:c01::241;

Authentication-Results: mx.google.com;

spf=pass (google.com: domain of [email protected] designates 2607:f8b0:4002:c01::241 as permitted sender) smtp.mail=[email protected];

dkim=pass [email protected];

dmarc=pass (p=NONE dis=NONE) header.from=gmail.com

Received: by mail-yh0-f65.google.com with SMTP id i57so1229540yha.8

for <[email protected]>; Mon, 02 Jun 2014 04:55:23 -0700 (PDT)

Return-Path: <[email protected]>

Received-SPF: pass (google.com: domain of [email protected] designates 10.236.55.201 as permitted sender) client-ip=10.236.55.201

X-Received: from mr.google.com ([10.236.55.201])

by 10.236.55.201 with SMTP id k49mr50865768yhc.105.1401710122405 (num_hops = 1);

Mon, 02 Jun 2014 04:55:22 -0700 (PDT)

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;

d=gmail.com; s=20120113;

h=mime-version:date:message-id:subject:from:to:content-type;

bh=c29e2I2Jft9BtjlfNJXqistA+6fKbhUKSI98cphwpKs=;

b=HhU6RQ36k7vhace/lQbGQ1ap+zuIVOoCsBFR/XAIH9I8EWVMcfNTvYADGsKRGz/amn

sWSJMGBSS+zdxwEm25NVOgDF1ZVcL7nhFjw09x4Urfk//YoTIXe+nkZ45RSC/ssNOEJX

IpaI19/+P2kFXWGjkTxR1f3gk4BOyoqOzJQ/vWnO6qjZ8Vv8HAyIlQSzbHPcAfdV2XGX

CN/FnZ2Wv3YaZsCMEmE0RCg8RL6FXzabegNwrLWgaekGjIRZGjP0IKPizoFq5Yx/RaXj

oIzTKNYgfvBMXkggdeWmr1/XJvradjeiYumTHJO5m/YZFntNMchK4JNVqpdoPQ92FyxO

8Dag==

MIME-Version: 1.0

X-Received: by 10.236.55.201 with SMTP id k49mr50865768yhc.105.1401710122398;

Mon, 02 Jun 2014 04:55:22 -0700 (PDT)

Received: by 10.170.123.136 with HTTP; Mon, 2 Jun 2014 04:55:22 -0700 (PDT)

Date: Mon, 2 Jun 2014 14:55:22 +0300

Message-ID: <CAMryuSAoD4HM+chCHSNqk824szwU5+-kSfOWXeWMHbaLcL5JRQ@mail.gmail.com>

Subject: sss

From: Optimum Vulnerability <[email protected]>

To: Harris HashNotes <[email protected]>

Content-Type: multipart/alternative; boundary=bcaec50b50dcec7a9d04fad91105



--bcaec50b50dcec7a9d04fad91105

Content-Type: text/plain; charset=UTF-8



aaaaccacacac



--bcaec50b50dcec7a9d04fad91105

Content-Type: text/html; charset=UTF-8



<div dir="ltr">aaaaccacacac<br></div>



--bcaec50b50dcec7a9d04fad91105--

1
[Attachments=(ArrayList) [], BCCField=, Body=<div dir="ltr">aaaaccacacac<br></div>
, CCField=, ContentType= text/plain; charset=UTF-8, FromField= Optimum Vulnerability <[email protected]>
, ToField= Harris HashNotes <[email protected]>, Subject= sss, IsInitialized=true
]



*****************************************************************************
(Greek)

Delivered-To: [email protected]

Received: by 10.112.253.37 with SMTP id zx5csp97760lbc;

Mon, 2 Jun 2014 04:53:05 -0700 (PDT)

X-Received: by 10.236.160.67 with SMTP id t43mr51459604yhk.11.1401709955756;

Mon, 02 Jun 2014 04:52:35 -0700 (PDT)

Return-Path: <[email protected]>

Received: from mail-yk0-x243.google.com (mail-yk0-x243.google.com [2607:f8b0:4002:c07::243])

by mx.google.com with ESMTPS id f49si22932117yhl.4.2014.06.02.04.52.35

for <[email protected]>

(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);

Mon, 02 Jun 2014 04:52:35 -0700 (PDT)

Received-SPF: pass (google.com: domain of [email protected] designates 2607:f8b0:4002:c07::243 as permitted sender) client-ip=2607:f8b0:4002:c07::243;

Authentication-Results: mx.google.com;

spf=pass (google.com: domain of [email protected] designates 2607:f8b0:4002:c07::243 as permitted sender) smtp.mail=[email protected];

dkim=pass [email protected];

dmarc=pass (p=NONE dis=NONE) header.from=gmail.com

Received: by mail-yk0-x243.google.com with SMTP id 200so792719ykr.10

for <[email protected]>; Mon, 02 Jun 2014 04:52:35 -0700 (PDT)

Return-Path: <[email protected]>

Received-SPF: pass (google.com: domain of [email protected] designates 10.236.129.227 as permitted sender) client-ip=10.236.129.227

X-Received: from mr.google.com ([10.236.129.227])

by 10.236.129.227 with SMTP id h63mr2828220yhi.148.1401709954185 (num_hops = 1);

Mon, 02 Jun 2014 04:52:34 -0700 (PDT)

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;

d=gmail.com; s=20120113;

h=mime-version:date:message-id:subject:from:to:content-type;

bh=VXbEUc1589bdgwiu19HRg3SJTqEK/9Kz7qo9W5mc1yU=;

b=WMwQgEXyLi+05lMgT6hqSwvvRl9FEZ+SmtBtHyXRY0r+WP8rsjMQyfCJOjLbnytUWR

WutQQ6394bo/NLsVhRGKDfJfgi9FlvTEu5awpzl+vsexfq44DnjthUHRjRvrU+uLzna8

sL6r+5rIIxLhvNJGa8KGgN0HL9SdzWmZqF2Bmiugd67d+akWlmoetdewFEJYJmGaHTML

jgcHQ0jHEszJpyK/A/V5WcpjA8IM2HALDSZWGkiL4tM5Rv2z6RCjIBY/Gg56vAQXO/WD

3bFVVbRbXuR5ZZnWjdtgqw6Ym54ccJMJ/OrcQxCp9ZaNPZSpTQ0H6tk9XC/HAjiFrHux

kphw==

MIME-Version: 1.0

X-Received: by 10.236.129.227 with SMTP id h63mr2828220yhi.148.1401709954181;

Mon, 02 Jun 2014 04:52:34 -0700 (PDT)

Received: by 10.170.123.136 with HTTP; Mon, 2 Jun 2014 04:52:34 -0700 (PDT)

Date: Mon, 2 Jun 2014 14:52:34 +0300

Message-ID: <CAMryuSAYsGJAEWXZi3OX=[email protected]>

Subject: Giouxoy

From: Optimum Vulnerability <[email protected]>

To: Harris HashNotes <[email protected]>

Content-Type: multipart/alternative; boundary=20cf301afd2de5ad1204fad9077d



--20cf301afd2de5ad1204fad9077d

Content-Type: text/plain; charset=UTF-8

Content-Transfer-Encoding: base64



zqTOt8+CIM61zrvOu86xzrTOv8+CIM+EzrEgz4DOsc65zrTOuc6xICNsYWxha2lzDQo=

--20cf301afd2de5ad1204fad9077d

Content-Type: text/html; charset=UTF-8

Content-Transfer-Encoding: base64



PGRpdiBkaXI9Imx0ciI+zqTOt8+CIM61zrvOu86xzrTOv8+CIM+EzrEgz4DOsc65zrTOuc6xICNs

YWxha2lzPGJyPjwvZGl2Pg0K

--20cf301afd2de5ad1204fad9077d--

1
file saved: attachment1 (72 bytes)
[Attachments=(ArrayList) [attachment1], BCCField=, Body=
, CCField=, ContentType= text/plain; charset=UTF-8, FromField= Optimum Vulnerability <[email protected]>
, ToField= Harris HashNotes <[email protected]>, Subject= Giouxoy, IsInitialized=true
]
 
Upvote 0

harris_offease

Member
Licensed User
Longtime User
I Think the problem is here :

Sub HandlePart(Headers As String, Body As String, Msg As Message)
If Regex.Matcher2("Content-Transfer-Encoding:\s*base64", _
Regex.CASE_INSENSITIVE, Headers).Find Then
'we are dealing with an attachment
Dim filename As String
Dim m As Matcher
m = Regex.Matcher2("filename=\s*q([^q]+)q".Replace("q", QUOTE), Regex.CASE_INSENSITIVE, Headers)
If m.Find Then filename = m.Group(1) Else filename = "attachment" & (Msg.Attachments.Size + 1)
Dim su As StringUtils
Dim out As OutputStream
out = File.OpenOutput(dir, filename, False)
Dim data() As Byte
data = su.DecodeBase64(Body)
Log("file saved: " & filename & " (" & data.Length & " bytes)")
out.WriteBytes(data, 0, data.Length)
out.Close
Msg.Attachments.Add(filename)
Else If Regex.Matcher2("Content-Type:\s*text/", _
Regex.CASE_INSENSITIVE, Headers).Find Then
Msg.Body = Body
End If
End Sub

When there are greek letters, the Header is Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: base64

When there are only english letters it is Content-Type: text/html; charset=UTF-8

So it when there are greek letters, it thinks there is an attachment, and saves it..
 
Upvote 0

harris_offease

Member
Licensed User
Longtime User
Yes, changed it and it works perfectly from google email :)) Now Need to change the hotmail as well, (it is iso-8859-7) from it .. :) Thank you very much :)
 
Upvote 0
Top