Dependent on the introduction of Hutool
<!--邮箱验证hutool--> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>4.6.3</version> </dependency> <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <version>1.4.7</version> </dependency>
Mail.setting configuration file
# SMTP mail server address, optional, defaults to smtp. <Sender's mail suffix> Host = smtp.yeah.net SMTP mail server # port, optional, default 25 Port = 25 # Sender (must be correct otherwise, send failed) from [email protected] = # username, the default is the sender's mailbox prefix the user = hutool # password (note that some mailboxes require a separate password for the SMTP service, details to view help) Pass = q1w2e3
Write test classes
MailTest class {public public static void main (String [] args) { MailUtil.sendText ( "mailbox you want to send," "message header", "content"); } }
For details, please click: https://www.hutool.cn/docs/#/extra/%E9%82%AE%E4%BB%B6%E5%B7%A5%E5%85%B7-MailUtil