B4J Question How to send email via smtp.libero.it ?

amorosik

Expert
Licensed User
I'm try to send email with smtp.libero.it server with superbasic code
Obviously the username and password are fictitious
B4J 10.0
JNET library 1.81

B4X:
Dim smtp As SMTP
    smtp.Initialize("smtp.libero.it","587","username@libero.it","password", "SMTP")
 
    Dim destinatari As String = "gigetto@rai.it, mariuccia@tim.it"
    Dim destinatari_array() As String = Regex.Split(",", destinatari.Trim)

    For Each email As String In destinatari_array
        smtp.To.Add(email.Trim)
        Next

    smtp.UseSSL = True
    smtp.StartTLSMode=True
 
    smtp.Sender = "username@libero.it"
    smtp.AuthMethod = smtp.AUTH_LOGIN
    smtp.HtmlBody = True
    smtp.Subject = "Oggetto email inviata"
    smtp.Body = "Corpo dell'email inviata"
 
    Wait For (smtp.Send) SMTP_MessageSent (Success As Boolean)
    If Success Then
        Log("Message sent successfully")
    Else
        Log("Error sending message")
        Log(LastException)
    End If


The following error is always returned on the line "Wait For (smtp.Send) SMTP_MessageSent (Success As Boolean)"



B4X:
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:131)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:325)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:268)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:263)
    at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:645)
    at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.onCertificate(CertificateMessage.java:464)
    at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(CertificateMessage.java:360)
    at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:396)
    at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:445)
    at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:423)
    at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:182)
    at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:167)
    at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1462)
    at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1370)
    at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:437)
    at org.apache.commons.net.smtp.AuthenticatingSMTPClient.performSSLNegotiation(AuthenticatingSMTPClient.java:284)
    at org.apache.commons.net.smtp.AuthenticatingSMTPClient.execTLS(AuthenticatingSMTPClient.java:264)
    at anywheresoftware.b4a.net.SMTPWrapper$1.run(SMTPWrapper.java:267)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
    at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:439)
    at java.base/sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:306)
    at java.base/sun.security.validator.Validator.validate(Validator.java:264)
    at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231)
    at java.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:132)
    at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:629)
    ... 18 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at java.base/sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
    at java.base/sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
    at java.base/java.security.cert.CertPathBuilder.build(CertPathBuilder.java:297)
    at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:434)
    ... 23 more

If I try to use the same data to send using Swithmail, sending is correct, and therefore even if the port used is 587 instead of 465 I imagine that the data used is correct
What could the error I receive depend on?
 
Last edited:

drgottjr

Expert
Licensed User
Longtime User
not so. they want a city and phone. it's easy enough to put roma, but it didn't take my phone (not italian), and i didn't have yours. plus i didn't know what would happen if i did put yours (which they presumably already have). plus i didn't know what was coming next.
you really don't think we wouldn't try to get our own accounts to try to help you?
 
Upvote 0

teddybear

Well-Known Member
Licensed User
This step we need a phone to verify account.
Cellulare.png
 
Upvote 0

amorosik

Expert
Licensed User
The libero.it system asks you to verify by phone because you entered a phone number during registration
If you enter an email during registration, it will not ask you to verify by phone
 
Upvote 0

teddybear

Well-Known Member
Licensed User
The libero.it system asks you to verify by phone because you entered a phone number during registration
If you enter an email during registration, it will not ask you to verify by phone
I just entered a mail not a phone number.
 
Upvote 0
Top