Android Question Error 503 Bad sequence of commands in smtp send email

joaquinortiz

Active Member
Licensed User
Longtime User
I have the following code and when I send an e-mail attaching a file, it shows me this message.

Send mail:
            '///////////////////////////////////////////////////
            myEmail.gEmailTO = txtEmailTo.Text
            '///////////////////////////////////////////////////
            'Asigna el nombre del archivo
            lExcelFileName = myGlobalVariables.gExcelQuickSCAN & "_" & fechahoy & TimeHoy & ".xls"
'            fcnExportaEntradas(lExcelFileName)
            myAccess.ExportaReciboCiegoEXCEL(lQuery,lExcelFileName)
            ''''''''''''''''''///////////////////////////
            Dim mail As SMTP
            mail.Initialize(myEmail.gServerOUT,myEmail.gPortOUT,myEmail.gEmailFROM,myEmail.gEmailPassword,"mail")
            mail.AddAttachment(myGlobalVariables.gSQLDataBasePath,lExcelFileName)
            mail.UseSSL = True
            mail.To.Add(myEmail.gEmailTO)
            mail.HtmlBody = True
            mail.Body = myEmail.gEmailBODY 'html.ToString
            myEmail.gEmailSubject = myGlobalVariables.gSistema & " - Archivo adjunto " & lExcelFileName
            mail.Subject = myEmail.gEmailSubject 'title
            Dim obj As Object = mail.Send
            wait for (obj) mail_MessageSent(Success As Boolean)
            If Success Then
'                blnSendFile = True
'                'ToastMessageShow("Enviado correctamente",False)
                Msgbox2Async("Se envió el archivo excel " & lExcelFileName & " al correo: " & txtEmailTo.Text.Trim, myGlobalVariables.gSistema, "Si", "", "No", Null, False)
                Wait For Msgbox_Result (Result As Int)
                If Result = DialogResponse.POSITIVE Then
                    SalirFormulario
                End If
            Else
                Msgbox2Async("No se pudo enviar el archivo excel: " & CRLF & LastException.Message, myGlobalVariables.gSistema, "Si", "", "No", Null, False)
                Wait For Msgbox_Result (Result As Int)
                If Result = DialogResponse.POSITIVE Then
                    SalirFormulario
                End If
'                blnSendFile = False
            End If
 

JohnC

Expert
Licensed User
Longtime User
Have you reviewed these threads?



 
Upvote 0

joaquinortiz

Active Member
Licensed User
Longtime User
I'll already check it....let me check it again.

But, there is something that i'm confused.

For example.
IF my sender e-mail is: myemail@basicwms.com
And my to e-mail is: myemail@gmail.com or myemail@id-consultores.com

It shows me this error.

But if I change my e-mailTo to myemail2@basicwms.com <-- It's works and I recieve the e-mail.

What could be the problem?
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Try adding this line:

B4X:
mail.MailFrom = "myemail@basicwms.com"
 
Upvote 0

joaquinortiz

Active Member
Licensed User
Longtime User
Now, I'm recieveing the following error.

org.apache.commons.net.smtp.SMTPConnectionClosedException: Connection closed without indication
 
Upvote 0

joaquinortiz

Active Member
Licensed User
Longtime User
are you sure that the settings are correct for gmail?
Yes, it's correcto.

The receiver can be: joaquinortiz29@gmail.com or jortiz@id-consultores.com

The sender that I'm using is 'no-reply@basicwms.com'

mail.Initialize("basicwms.com",465,"no-reply@basicwms.com","mypassword","mail")
mail. UseSSL = True

With this, the error still Error 503 Bad sequence...etc, etc.
I recently talked to my emails provider, and he told me the following.

If the e-mail is not authenticated with the basicwms mail user and mail password then it can only send to the same domain and not outside, but apparently, you are sending it authenticated, check it well and google what may be happening.

Also I tried the following:
mail.Initialize("basicwms.com",587,"no-reply@basicwms.com","mypassword","mail")
mail.StartTLSMode = True

And it throws me the following error:
java.net.ConnectException: Connection Timed out.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Try commenting out the mail.StartTLSMode = True line, and add this line:

Mail.AuthMethod = mail.AUTH_LOGIN
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Did you fix the issue?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…