Android Question Emails sent using SMTP - Stopped Sending

PhilipK

Member
Licensed User
Longtime User
Hi

My app has been sending scheduled emails, in the background, for many months. Recently, on one day last week, all emails stopped.

So I loaded a test app which sends a single email, using the same connection info and initiated on a button click (code below).

I have updated the NET library to 1.62 and spent hours trying to find the reason for failure:

- No emails, although using same (original) code.

- Tested repeatedly on two android phones.

- App reports emails having gone (SMTP_MessageSent(Success)=True), no errors

- There appears to be data indicating arrows on network connection icon during send.

- I have rebooted the phones to reset any potential anomalies.

- Played with the StartTLS and UseSSL settings to check if it's incorrect.

No go.

However, I can send an email from a PC using the same email accounts (server, user, password, starttls info.) and it works.

The test code:
B4X:
Sub Process_Globals
    Dim SMTP1 As SMTP
    Dim tmrWait As Timer
End Sub

Sub Globals
    Private Button1 As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Main")
    SMTP1.Initialize("xxx", 587, "xxxxx", "xxx", "SMTP")
    SMTP1.StartTLSMode=True
    SMTP1.UseSSL=False

    DoEvents
    tmrWait.Initialize("tmrWait",10000)
    tmrWait.Enabled=True

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub Email

Try
        SMTP1.To.Add("xxxxxx")
        SMTP1.Subject ="Trial email from android"
       
        SMTP1.Body = "Have you got it?"
        SMTP1.Send
        DoEvents
        Log("Sent email")
        ToastMessageShow("Sent test email",False)
       
Catch
        Log("ERROR: " & LastException.Message)

End Try           
   
End Sub
Sub tmrWait_Tick
    tmrWait.Enabled=False
    ExitApplication
End Sub
Sub SMTP_MessageSent(Success As Boolean)
   Log("SMTP send: " & Success )
    If Success Then
         ToastMessageShow("Success!",True)
      Else
         ToastMessageShow("Failed to send!",True)
         Log(LastException.Message)
     End If  
End Sub
Sub Button1_Click
    Email
End Sub

All ideas welcome!!

Thanks.
 

lemonisdead

Well-Known Member
Licensed User
Longtime User
No really powerful idea but a suggestion: move the timer.enable to the
SMTP_MessageSent sub
And another stupid one : check any spam folder or filter

Edit: a last one : move the SMTP code to a service (in case your app is being paused)

Edit1: just seen the name of the Email sub. Perhaps rename it too
 
Last edited:
Upvote 0

PhilipK

Member
Licensed User
Longtime User
Thanks for the ideas.

Now RESOLVED: By adding the latest Net v1.62 library: SMTP1.AuthMethod=SMTP1.AUTH_LOGIN

Now can't understand how it worked without!
 
Upvote 0
Top