Function description of sending mail using components in spring framework

The spring framework was created due to the complexity of software development. Spring uses basic JavaBeans to do things that previously could only be done by EJBs. However, the use of spring is not limited to server-side development. In terms of simplicity, testability and loose coupling, most Java applications can benefit from spring.

First, enter your QQ email and modify the account information in the settings

Then come to the bottom

Click open, then send the corresponding information to the specified number by mobile phone, and then click I have sent

Obtain authorization code

Note:

Here, I believe you have opened the SMTP service so that you can send mail in Java code

Next is the use of mail services in spring

First, the configuration information uses port 587. At the beginning, I struggled with port 465 for a long time (error details of using port 465). You can try. The default port 25 should also be inappropriate

Jar package introduced with maven

The following is just a simple example of a tool class. Don't be surprised

reminder:

This is the way to embed pictures javaxmail PNG and messagehelper addInline(file.getFilename(),file); Here's file Getfilename () is consistent

Now there is only one step to go, that is Ctrl + F11. If there is anything wrong, please put forward it and make common progress

summary

The above is what Xiaobian introduced to you. I use the components in the spring framework to send emails. I hope it will help you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>