javamail
The interaction between java and email
In development, you will encounter the situation of sending emails and checking emails, you need to use javamail, where SMTP is for sending emails, and POP3 and IMAP are for receiving emails (for example, viewing the email information in the inbox in the mail server)
Commonly used ports
POP3: The default port is: 110 (if ssl secure link is checked, the port number is 995)
SMTP: The default port is: 25 (if ssl secure link is checked, the port number is 994)
IMAP: The default port is: 143 (if ssl secure link is checked, the port number is 993)
Basic configuration for reading mail
// connection properties final Properties props = new Properties(); props.setProperty("mail.store.protocol", "imap"); props.setProperty("mail.imap.port", "993"); props.setProperty("mail.imap.host", "pop.gmail.com"); props.setProperty("mail.imap.ssl.enable", "true"); // create session to the mail server final Session session = Session.getInstance(props, null); final Store store = session.getStore("imap"); store.connect("userName", "password");
One must pay attention to whether there is SSL, and whether POP3 or IMAP is used
Email reference
Link template: http://blog.csdn.net/zoufaxiang/article/details/50847965
Get email content or attachments: http://blog.csdn.net/aassdd_zz/article/details/8204344
Create a folder: http://mjbb.iteye.com/blog/793673