It's disappointing that I can't get the SMTP to send email thru Outlook.
I've tried many settings and always get back this error:
(SMTPConnectionClosedException) org.apache.commons.net.smtp.SMTPConnectionClosedException: Connection closed without indication.
Many users have posted their methods to the forum, which I've tried, but many of these users are unable to send email - mostly using other providers.
I eventually found a post that Erel replied to where the poster was wanting to find and read SMTP documentation. Erel posted a screen shot of the SMTP documentation, instead of posting the URL to the documentation.
I applied what the documentation said to my code, still didn't work.
This is my last code try and it gets the above error.
Has this jNet library and the SMTP methods even been tested lately by Anywhere Software? Seems not as the basic workings do not work.
If the jNet library is not going to work, time to move on to a host like MailGun, which I'm setting up now. Complicated to setup but will work I'm sure.
I've tried many settings and always get back this error:
(SMTPConnectionClosedException) org.apache.commons.net.smtp.SMTPConnectionClosedException: Connection closed without indication.
Many users have posted their methods to the forum, which I've tried, but many of these users are unable to send email - mostly using other providers.
I eventually found a post that Erel replied to where the poster was wanting to find and read SMTP documentation. Erel posted a screen shot of the SMTP documentation, instead of posting the URL to the documentation.
I applied what the documentation said to my code, still didn't work.
This is my last code try and it gets the above error.
Has this jNet library and the SMTP methods even been tested lately by Anywhere Software? Seems not as the basic workings do not work.
If the jNet library is not going to work, time to move on to a host like MailGun, which I'm setting up now. Complicated to setup but will work I'm sure.
B4X:
Sub Process_Globals
Private fx As JFX
Private smtp As SMTP
Private smtpServer As String = "smtp.office365.com"
Private smtpPort As Int = 587
Private smtpUser As String = "[email protected]"
Private smtpPassword As String = "xxxxxxxxxxxxxx"
Private Recipient As String = "[email protected]"
End Sub
Public Sub Send(ToAddress As String, Subject As String, Body As String) As ResumableSub
smtp.Initialize(smtpServer, smtpPort, smtpUser, smtpPassword, "SMTP")
Log("Initialized")
smtp.StartTLSMode = True
smtp.UseSSL = False
smtp.AuthMethod = smtp.AUTH_LOGIN
Log("Connection methods set")
smtp.Sender = smtpUser
smtp.To.Add(Recipient)
smtp.Subject = Subject
smtp.HtmlBody = True
smtp.Body = Body
Log("Email Body set")
'Dim trustall As CustomTrustManager
'trustall.InitializeAcceptAll
'smtp.SetCustomSSLTrustManager(trustall)
'smtp.AdditionalHeaders.Put("Content-Type", "text/html; charset=utf-8")
Wait For (smtp.Send) SMTP_MessageSent (Success As Boolean)
If Success Then
Log("Email sent: " & ToAddress)
Else
Log("Email FAILED:")
Log(LastException)
End If
Return Success
End Sub