B4A Library New Net library - Android FTP, SMTP and POP3

Status
Not open for further replies.

rleiman

Well-Known Member
Licensed User
Longtime User
I just put some coding in the app to catch errors.

I get an error stating:

B4X:
Empty writer returned
Authentication Required

How do I code for Authentication?

Thanks.
 

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Everyone,

Got it working. RFman had the same problem so I did what RFman did:

From RFman
Ater getting this error, got a gmail indicating that if I want my app to have access to sent gmail to change my security settings at the link provided. I did so, and the gmail now works with my app.
 

GDO

Member
Licensed User
Longtime User
Hello,
I 've got a trouble with POP3.
I can't receive message bigger than 1.4 Mb and the trouble is, there is no error message or other informations to help me.
I use the lastest net library with the example from Erel and a Gmail account (but same trouble with other provider).
Any idea ?
Or could you please make a test with a message and 2 Mb jpeg attachment ?
Thanks.
 

GDO

Member
Licensed User
Longtime User
Was the DownloadCompleted event raised?

Have you checked the unfiltered logs?

I've seen nothing special in logs (nothing more with or without the trouble).
And No, DownloadCompleted event is never raised when trouble (with 1.5 Mb attachment or biger), nothing happens.

is it working for you with 1.5 Mb ?
 

GDO

Member
Licensed User
Longtime User
I am going crazy ...
The good news, it's working with 1.5 Mb attachment. Why ? I don't know ...

I made a bunch of tests and sometimes it's good, sometimes it is not !?
I suppose when something is going wrong the others tests are meanless.

So I tested again and again with reboot everytime something is wrong.

Now, it's working with 4.5 Mb attachment (in fact no more than 5 Mb for the whole mail) and I think it is ok according to the provider.

The trouble is, but I can live with it, when I try to download mails in a loop, sometimes it's ok but sometimes the big one is not ok.
So there is a limit for one mail and I think that there is a limit for a group of mails in one session.

Any idea ?

Anyway, Thank you for your help.

My code, from your code :

#Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#ApplicationLabel: POP3 Example
#VersionCode: 2
#VersionName: 1.01
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region

Sub Process_Globals
Dim pop As POP3
End Sub

Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
pop.Initialize("pop.gmail.com", 995, "xxx@gmail.com", "xxx", "pop")
pop.UseSSL = True
End If
pop.ListMessages
End Sub

Sub POP_ListCompleted (Success As Boolean, Messages As Map)
If Success = False Then
Log(LastException.Message)
Else
'download all messages
'change last parameter to True if you want to delete the messages from the server
For i = 0 To Messages.Size - 1
pop.DownloadMessage(Messages.GetKeyAt(i), False)
Next
End If
pop.Close
Log("Terminé")
End Sub

Sub POP_DownloadCompleted (Success As Boolean, MessageId As Int, MessageText As String)
If Success = False Then
Log(LastException.Message)
Else
'Parse the mail
' Dim m As Message
Try
' m = MailParser.ParseMail(MessageText, File.DirRootExternal)
' Log(m.DateField & CRLF & m.FromField & CRLF & m.Subject & CRLF & m.Body & CRLF & m.Attachments)
' ToastMessageShow(m.DateField & CRLF & m.FromField & CRLF & m.Subject & CRLF & m.Body & CRLF & m.Attachments, True)

File.WriteString(File.DirRootExternal, "toto" & MessageId & ".txt", MessageText)
' Log(File.Size(File.DirRootExternal, "toto" & MessageId & ".txt"))
ToastMessageShow("FICHIER SAUVEGARDé --------------------", True)
Catch
Log(LastException.Message)
End Try
End If
End Sub

Thanks again !

 

fransvlaarhoven

Active Member
Licensed User
Longtime User
Hello,

I have a problem sending Mail using SMTP:

the body of the sended mail is always in the form:

Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

is it possible to send mail where the body is encoded as:

Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64

Thanks,
 

RobM

Member
Licensed User
Longtime User
Some users of my app (3 out of 10) are reporting this error when sending an email with SMTP.

org.apache.commoms.net.smtp.SMTPConnectionClosedException: Connection closed without indication.

They have tried sending with and without wifi. The email in question is a html table 8kb in size no attachments.
The same email can be sent ok using the phones default email client.
I cannot reproduce the error.

Any thoughts?
 

RobM

Member
Licensed User
Longtime User
All the settings are done in the app. The user supplies their user name and password.

The same credentials are used to download emails, which is working ok.

The users all work for the same company and have an office 365 account. All have the same phone.

Would increasing the timeout help ?

Edit:
A user of the app was on a clients site connected to his WiFi. He got the same error when trying to send. Disconnecting from the Wifi and sending via 3g worked for this user.
Don't know if this is of any help.
 
Last edited:

RobM

Member
Licensed User
Longtime User
Re Reply 334 and 336
Still having issues with some users not being able to send via SMTP to the office365 server. Can download ok.
Users can send if they use gmail SMTP instead. (Much quicker to send)

This is the reply from IT services.

Hi Rob,
It’s a MS hosted system that we already have working for other devices in the business. The chances of the issue being server side are slim to nothing. The problem will be with the app.
It’s possible the correct SSL/TLS isn’t supported by the app and is thus being dropped by MS. Beyond that I can’t really help sorry.


I do have the gmail send option as a workaround, but having users enter 2 sets of credentials is a bit messy.

One last plea for any suggestions.
 

RobM

Member
Licensed User
Longtime User
Unfortunately due to company policy it would not be possible to have access.

Thanks
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…