Statement: The material used in this column is written by the VIP students of the Kay Academy, who has the right to be anonymous and has the final right to interpret the article; The Edith Academy is designed to promote students to learn from each other on the basis of public notes.
Email Verification Code
Generally can use the mailbox to register the account, in the login, registration or forget the password and other operations, can use the mailbox to verify, so the mailbox verification code is also used more widely, but compared to SMS verification code, the mailbox verification code use less, because now is a person has a mobile phone number, but not necessarily have a mailbox account.
Use the mailbox to send the verification code, do not need to like SMS verification code to call the SMS Service API to send the verification code, but need to have a mailbox server capable of sending mail or use a third-party mailbox, such as 163, 126, QQ mailbox.
Mailbox servers or third-party mailboxes require the POP3, SMTP, and IMAP services to be turned on, because these services are enabled before they can be called by a third party to send mail.
Because it is troublesome to build a mailbox server myself, I use 163 of the mailbox as a demo here.
1. First you have to go to the mailbox to open the service, log in and click Settings to see the options for these services:
2. Set up the service, the first time you set up, you will need SMS verification, and then will ask you to set a password:
- To verify the SMS:
- Set Password:
- Complete:
The password for this setting is the authorization code to remember, when you send the message you need to use this authorization code.
Then we use Java to write a class to send the message, but before you write this code you have to get the jar package in the first, you need to use these third-party jar packages to implement the mail delivery:
Once you have the jar package, import the jar packages into the Lib directory under Web engineering:
With these jar packages, you can start writing code, we'll write a simple class to test the success of sending a message, code example:
Operation Result:
, the message can be sent normally, and the recipient can receive it.
Questions about the verification code for the message:
Sometimes the mail will be sent slowly, even can not send out. So the user in this case needs to wait, the most classic is that the icon of the circle will always be in the loop, in order to solve the problem of waiting, you can send the verification code sent to a queue collection, let it send in the background, so that the user will not be stuck in the current page to send the verification code:
Java Implementation Mailbox Verification code