Android Question android.system.ErrnoException: connect failed: ENETUNREACH (Network is unreachable)

Zeev Goldstein

Active Member
Licensed User
hi

i'm trying to send email from my app using gmail
on one phone it works
on the other one i get this error

both are android 9.1

this email account is set for low security so i can use it without 2 factors or gmail auth api

as said - one phone works perfectly on other i get this error

BTW - i get all permissions etc...

anyone can open my eyes ?

thanks
 

Zeev Goldstein

Active Member
Licensed User
Are you sure that the problematic device is connected to the internet?

Try to add this to the manifest editor:
B4X:
CreateResourceFromFile(Macro, Core.NetworkClearText)
thanks for your reply
yes - device is connected to the internet ans has full signal

the line you suggested made no change and i keep getting the same error
 

Zeev Goldstein

Active Member
Licensed User
i did try browsing to a few urls - all worked
there is no other error - the error i get is the one in the post title

i just try to send a simple email through gmail smtp - as said on one device works like charm on another one not and i get this error
 

Zeev Goldstein

Active Member
Licensed User
and this is the code i use

B4X:
Sub SendEmail()
    Dim mail As SMTP
    
    Dim SMTP_SSL_Port As Int = 465    'for SSL
    Dim SMTP_TLS_Port As Int = 587    'for TLS

    Try       
    
        mail.Initialize("smtp.google.com", 465, "MyUserName@gmail.com", "MyPassword", "SMTP")
        mail.UseSSL=True
        
        Dim M As Map
        M.Initialize
        M.Put("From","MySelf <MyUserName@gmail.com>")
        mail.AdditionalHeaders = M
        
        
        mail.To.Add("SMTP_SendTO")

        mail.Subject = "SMTP_Subject"
        mail.Body = "SMTP_Body"
        
        mail.AddAttachment(fPath, fName)
        
        mail.Send
        
        Wait For smtp_MessageSent(Success As Boolean)
        Log(Success)
        
        If Success = True Then
            ToastMessageShow("Message sent successfully", True)
        Else
            ToastMessageShow("Error sending message", True)
            Log(LastException.Message)
        End If

    Catch
        Log(LastException.Message)
        
    End Try
    
End Sub
 

Zeev Goldstein

Active Member
Licensed User
Thanks
That's odd
Both phones are side by side
Both have full internet access
One works one doesn't
I've checked on wifi and on cellular
What else can i check or do?
 

Zeev Goldstein

Active Member
Licensed User
Found the problem & easily resolved.
There was nothing wrong in the app or phone or network.
I have adguard and it was blocking network access.
Marked the app as safe and voila it works like charm.
Silly me..
Thank you all who tried to help
 
Top