Android Question [solved] Net Library: SMTP.Send sometimes doesn't trigger MessageSent

Creideiki

Active Member
Licensed User
Longtime User
Hi,
I'm creating EMails in a service. Sometimes after SMTP.Send the SMTP_MessageSent sub is not triggered. Code like that:
B4X:
' Service
Sub Process_Globals
    dim SMTP1 as SMTP
End Sub

Sub sendEmail
    SMTP1.Initialize(..., "SMTP1")
    [... Setup SMTP1 ...]
    SMTP1.Send
    ToastMessageShow("sending message...")
End Sub

Sub SMTP1_MessageSent(Success As Boolean)
    If Success Then
        ToastMessageShow("message sent.")
    Else
        ToastMessageShow(LastException.Message)
    End If
End Sub

Most times it succeeds normally. In some cases neither "message sent" nor an errror message is shown.

Are there known issues? Has anybody an idea why the SMTP1_MessageSent is never called?
 

Creideiki

Active Member
Licensed User
Longtime User
Hm... are the toast messages doing something bad?

I have log messages in the original code indeed... the toasts are for the customer to see whats going on.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
If you want to have a backup in case the messagesent event doesn't occur, you could add a 1 minute timer and call it "tmrSMTPTimeout" and start the timer when you do the .Send.

Then if the _MessageSent event properly triggers, do a tmrSMTPTimeout.enabled = false to prevent the timer from falsely triggering.

And if the tmr_Tick Event triggers, then handle the timeout condition.
 
Last edited:
Upvote 0

Creideiki

Active Member
Licensed User
Longtime User
@Erel: ok, that's what I thought. But I have logs in the original app. :)
@JohnC: well, yes, that's an idea... but I still don't know if the mail was sent or not.

Is the source code available from the Net Library? I really would like to know in which cases it is possible that the MessageSent-Sub isn't called...
 
Upvote 0

Creideiki

Active Member
Licensed User
Longtime User
Wireshark is your friend. ;)
The problem is, that Android tries to contact the SMTP server via IPv6... the SMTP server listens on IPv6, but the firewall filters it... o_O

I will create a timer so the customer gets the info. And somebody has to fix the firewall. :D

Thanks to all for the support.
 
Upvote 0
Top