用JavaMail的imap协议连接邮箱并收取邮件,代码如下: import javax.mail.*; import javax.mail.internet.InternetAddress; import javax.mail.search.SubjectTerm; import org.springframework.stereotype.Service; import java.util.Properties; @Service public class EmailService { public void …