Hi, I'm trying to send a gmail through a B4J app but it's not working. I've updated my cacerts in Java and tested it with keytool and that's OK.
My code is:
I tried without using:
and:
But got the following error:
javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:128)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:259)
when Including:
I get the error:
java.lang.RuntimeException: Empty writer returned: 530-5.7.0 Authentication Required. Learn more at
530 5.7.0 https://support.google.com/mail/?p=WantAuthError gy15-20020a05600c880f00b003f7f475c3bcsm9887218wmb.1 - gsmtp
at anywheresoftware.b4a.net.SMTPWrapper$1.run(SMTPWrapper.java:312)
and support.google.com/mail/ did not help.
when I add:
I get an error:
java.net.SocketTimeoutException: Read timed out
When I use my gmail manually it works OK.
Would really appreciate some help.
My code is:
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
smtp.Initialize("smtp.gmail.com", 465, "abc@gmail.com", "defgh", "SMTP")
smtp.UseSSL = True
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Private Sub GenerateCodeBtn_MouseClicked (EventData As MouseEvent)
smtp.To.Add("xxx@gmail.com")
smtp.Body = "body"
smtp.Subject = "Test"
smtp.UseSSL = True
smtp.StartTLSMode=True
Dim trustall As CustomTrustManager
trustall.InitializeAcceptAll
smtp.SetCustomSSLTrustManager(trustall)
smtp.AuthMethod = smtp.AUTH_LOGIN
smtp.Send
Log("sending message")
End Sub
I tried without using:
B4X:
smtp.StartTLSMode=True
B4X:
Dim trustall As CustomTrustManager
trustall.InitializeAcceptAll
smtp.SetCustomSSLTrustManager(trustall)
smtp.AuthMethod = smtp.AUTH_LOGIN
But got the following error:
javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:128)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:259)
when Including:
B4X:
Dim trustall As CustomTrustManager
trustall.InitializeAcceptAll
smtp.SetCustomSSLTrustManager(trustall)
smtp.AuthMethod = smtp.AUTH_LOGIN
I get the error:
java.lang.RuntimeException: Empty writer returned: 530-5.7.0 Authentication Required. Learn more at
530 5.7.0 https://support.google.com/mail/?p=WantAuthError gy15-20020a05600c880f00b003f7f475c3bcsm9887218wmb.1 - gsmtp
at anywheresoftware.b4a.net.SMTPWrapper$1.run(SMTPWrapper.java:312)
and support.google.com/mail/ did not help.
when I add:
B4X:
smtp.StartTLSMode=True
I get an error:
java.net.SocketTimeoutException: Read timed out
When I use my gmail manually it works OK.
Would really appreciate some help.