send mail to Gmail account

后端 未结 5 1506
無奈伤痛
無奈伤痛 2020-12-17 03:03

I am sending mail from my Java app to Gmail Account. I had used the Java Mail API and it worked fine. But is it possible to send an e-mail without using the mail API in java

5条回答
  •  半阙折子戏
    2020-12-17 03:09

    In order to use a secure connection, use SSLSocket instead of Socket, like this:

    SSLSocket socket = (SSLSocket) ((SSLSocketFactory) SSLSocketFactory.getDefault()).createSocket(InetAddress.getByName("smtp.gmail.com"), 465);
    

提交回复
热议问题