简体   繁体   中英

Java Mail API password Verification

I am using Java Mail API to send an email. So I am getting email and password from user, I just want to check the password when they are enter their password, but I don't get any ideas to verify the password in Java Mail API. Can anyone help?

Question 2:

protected PasswordAuthentication getPasswordAuthentication() 
{
  return new PasswordAuthentication("xxx@gmail.com","*");
} 

What is use of the above the above method

To validate the password you have to use it. You don't have to send a message, but you do have to connect to the server and authenticate. Use the Transport.connect method. You can close the connection right away if you're not going to send the message soon, or you can save the Transport object for use later when you send the message and close it when you're done. Note that if you're waiting for user input between the Transport.connect (to validate the password) and the Transport.sendMessage (to send the message), the server may time out the connection and you'll have to reconnect before sending.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM