iOS Question SMTP doesn't send emails

Alex_197

Well-Known Member
Licensed User
Longtime User
Hi all.
I have a code that used to work about 5 days ago before I updated my phone to iOS 15,6
Here is a code
B4X:
Private Sub SendEmail(ErrorStr As String)
    Try
        
        Dim mail As SMTP
        Dim Email As String="[email protected]"
        Dim Port As Int=587
    
        mail.DebugLogs = True
        mail.Initialize("smtp.ionos.com", Port, "xxxx", "xxxx", "SMTP")
            
        mail.StartTLSMode = True
        mail.UseSSL=True
            
        mail.To.Add("[email protected]")
        mail.HtmlBody=True
        mail.Subject = "Subj"
        mail.Body =  ErrorStr
        mail.Sender =Email
        mail.HtmlBody=True
        mail.Send
        Wait For smtp_MessageSent(Success As Boolean)
        Log(Success)
        Log(LastException)
        
    Catch
        Log("SendEmail " & LastException)
    End Try
        
End Sub

If I use both mail.StartTLSMode = True and mail.UseSSL=True the error message is
Application_Start
Application_Active
C: Attempting to connect to server at: smtp.ionos.com:587
Beginning TLSv1...
false
<B4IExceptionWrapper: Error Domain=SKPSMTPMessageError Code=-3 "Unable to connect to the server." UserInfo={NSLocalizedDescription=Unable to connect to the server., NSLocalizedRecoverySuggestion=Try sending your message again later.}>


If I use only mail.StartTLSMode = True the error message is


Application_Start
Application_Active
C: Attempting to connect to server at: smtp.ionos.com:587
S: 220 perfora.net (mreueus003) Nemesis ESMTP Service ready
C: EHLO localhost

S: 250-perfora.net Hello localhost [68.197.191.153]
S: 250-8BITMIME
S: 250-AUTH LOGIN PLAIN
S: 250-SIZE 140000000
S: 250 STARTTLS
C: AUTH PLAIN AGluZm9AdGZjc2IuY29tAFRGQ3NiNjAwNjAr

S: 530 Must issue a STARTTLS command first

If I use only mail.StartTLSMode = True the error message is

Application_Start
Application_Active
C: Attempting to connect to server at: smtp.ionos.com:587
Beginning TLSv1...
false
<B4IExceptionWrapper: Error Domain=SKPSMTPMessageError Code=-3 "Unable to connect to the server." UserInfo={NSLocalizedDescription=Unable to connect to the server., NSLocalizedRecoverySuggestion=Try sending your message again later.}>


This code with the same credntials works fine in Android 10.

Both phones are connected to the same Wi-Fi and both have Internet.

Thanks.
 

Alex_197

Well-Known Member
Licensed User
Longtime User
Problem solved (still didn't get it why?)

If I use port 465 instead of 587 it works.

The same code works Ok with port 587 on Android 10.

P.S. port 465 doesn't work in Android.
 
Last edited:
Upvote 0
Top