Hi,
with the SSL and TLS I get an TimeOut Error:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
with 25 and both ssl and tls vars to false I get this
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
so it looks like the DEBUGGER MODE could send the email, but the SMTP Server does not response on SSL / TSL ...
and the responce on port 25 is an error message from the server ... is this right ?
But what does he want to tell me with the bad sequence ?
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
but than I can't change the port later in the app, am I right ?
so I removed the init from activity_create to the button_click event ...
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
the log says this with 25 (no SSL/TLS)
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
I have cut & paste the code from some examples and could not find what is missing ;-(
the same result if I put the init inside of CREATE
PS: NET 1.50 ... just loaded into the ExtraLib SubDir.
PPS:
very strange, if I use my own GMX.DE email account with ...
iPort = 465
SMTP.UseSSL = True
SMTP.StartTLSMode = False
than the eMail is send correct and true will come back.
With ...
iPort = 587
SMTP.UseSSL = False
SMTP.StartTLSMode = True
same error 503 ...
I found a SMTP Error PDF with this info:
503 now means that your server request a authentication ... but still use 25.
   
Is there a setting to tell SMTP-Lib to authenticate ?
   
   
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
this LIB just connect with (sUserName, sPassword), no PORT (means standard), no SSL / TLS ... in both cases this server does not responde on SSL / TLS connections, but give this 503 Error back with 25 (try) connection.
Is it possible to see the communication between both ?
			
			with the SSL and TLS I get an TimeOut Error:
			
				B4X:
			
		
		
		Try to send on: 587, SSL: false, TLS: true
TO: true count: 1 = hubert.brandel@gmx.de
After Send ...
SMTP send: false
java.net.SocketTimeoutException: Connection timed out
			
				B4X:
			
		
		
		java.lang.RuntimeException:
Empty writer returned: 503 Bad sequence of commands.
You must specify the recipients of a message before you can send itand the responce on port 25 is an error message from the server ... is this right ?
But what does he want to tell me with the bad sequence ?
			
				B4X:
			
		
		
		'Activity module
Sub Process_Globals
  ...
  Dim sDir As String = File.DirRootExternal  ' file attachement from ...
  Dim sFile As String = "HB-PDF.pdf"  ' name ...
  Dim sTo As String = "TargetEmailAdress@xyz.de"
  ' email über SMTP Server ... hierfür braucht man eine Internetverbindung und Klaus sollte eine eMail-Sendeadresse auf seinem Server anlegen.
  Dim SMTP As SMTP
  Dim sServer As String = "mail.server.de"  ' the SMTP Server
  Dim sSender As String = "ProgName@MySite.de" ' each app has its own eMailAdress to send from ...
  Dim sFrom As String = sSender
  Dim sPW As String = "..." ' the right password
  Dim iPort As Int  = I want to change this later in the APP
End Sub
' normaly this code should be here ...
Sub Activity_Create(FirstTime As Boolean)  
  If FirstTime Then
  Label1.Text = "eMail an: " & sTo
  Port25.Checked = True
  iPort = 25
  SMTP.Initialize(sServer, iPort, sFrom,sPW,"SMTP")
  SMTP.StartTLSMode = False
  SMTP.UseSSL = False
  End If   
End Subso I removed the init from activity_create to the button_click event ...
			
				B4X:
			
		
		
		Sub Send_Click
  If File.Exists(sDir,sFile) Then ' no file, no eMail
  ToastMessageShow("PDF senden (" & iPort & ")...",False) ' this shows the right port
  SMTP.Initialize(sServer, iPort, sFrom, sPW, "SMTP" ) ' look good in debugger
  If iPort = 25 Then
  SMTP.UseSSL = False
  SMTP.StartTLSMode = False
  Else
  If iPort = 465 Then
  SMTP.UseSSL = True
  SMTP.StartTLSMode = False
  End If  
  If iPort = 587 Then
  SMTP.UseSSL = False
  SMTP.StartTLSMode = True
  End If  
  End If  
  Log("Try to send on: " & iPort & ", SSL: " & SMTP.UseSSL & ", TLS: " & SMTP.StartTLSMode )
   
  SMTP.Sender = sSender ' no change if I remove this line
  SMTP.To.Add(sTo)
  Log("TO: " & SMTP.To.IsInitialized & " count: " & SMTP.To.Size & " = " & SMTP.To.Get(0) ) ' The log say, that I have 1 TO adress and it is right.
  SMTP.Subject = "Test eMail mit PDF Anhang"
  SMTP.Body = "Diese PDF habe ich gerade vom Smartphone erzeugt ;-) "
  SMTP.AddAttachment(sDir,sFile)
  SMTP.Send
  Log("After Send ...")   
  Else
  ToastMessageShow("PDF fehlt !",False)
  End If
End Sub
Sub SMTP_MessageSent(Success As Boolean)
  Log("SMTP send: " & Success )
  If Success Then
  ToastMessageShow("PDF wurde versandt !",True)
  Else
  ToastMessageShow("eMail Fehler !",True)
  Log(LastException.Message)
  End If  
End Sub
			
				B4X:
			
		
		
		...Try to send on: 25, SSL: false, TLS: false
TO: true count: 1 = hubert.brandel@gmx.de
After Send ...
SMTP send: false
java.lang.RuntimeException: Empty writer returned:
503 Bad sequence of commands. You must specify the recipients of a message before you can send itthe same result if I put the init inside of CREATE
PS: NET 1.50 ... just loaded into the ExtraLib SubDir.
PPS:
very strange, if I use my own GMX.DE email account with ...
iPort = 465
SMTP.UseSSL = True
SMTP.StartTLSMode = False
than the eMail is send correct and true will come back.
With ...
iPort = 587
SMTP.UseSSL = False
SMTP.StartTLSMode = True
same error 503 ...
I found a SMTP Error PDF with this info:
503 now means that your server request a authentication ... but still use 25.
Is there a setting to tell SMTP-Lib to authenticate ?
This server (with the 503 message and 25 as port) does NOT want a SSL connection, because normaly I use a Win32 bit EXE as CGI-EXE and send with the "ASINET" LIB from my win32 bit compiler. This LIB does not support SSL or TLS, just login with name and password. Its a hosteurope web server.It will always try to authenticate. Are you sure that the server expects an SSL connection?
			
				B4X:
			
		
		
		*----------------------------------------------------------------------------------------
Function SendAsinet(aEmpfaenger,cBetreff,cText,cProgPfad,aAttachFile,cAntwortAdresse) ' my function
  ...
  LOCAL oSmtp  := SMTPClient():new( GetSmtpServer(),,, oLog, 2 )
  LOCAL oSender  := MailAddress():new( "xxxxx@yyyy.de" )
  LOCAL oMail  := MIMEMessage():new()
  oMail:setFrom  ( oSender  ) // "xxxxx@yyyy.de"
  oMail:setSubject  ( cBetreff  ) // "Test eMail ..."
  oMail:setMessage  ( cText  ) // just the body text
  aeval(aEmpfaenger, {|cEmp| oMail:addRecipient(MailAddress():new(cEmp) ) }) ' adds all TO adresses
  oMail:addHeader( "Date", TimeStampSMTP() ) ' need to correct an error with date
  if ! aAttachFile = NIL
  aeval(aAttachFile, {|cFile| oMail:attachFile( cFile ) })
  endif
  IF oSmtp:connect( sUserName, sPassword ) ' fix from a ini file
  IF oSmtp:send( oMail )
  lOK := .t.
  ? "Message sent"
  ELSE
  ? "Unable to deliver message"
  ENDIF
  oSmtp:disconnect()
  ELSE
  ? "Unable to connect to mail server"
  ENDIF
RETURN lOKIs it possible to see the communication between both ?
 
				 
 
		 
 
		 
 
		