SpringBoot系列—简单的邮件系统 (2)

SpringbootMailApplication应用启动类实现了ApplicationRunner接口,应用启动成功就执行run方法,发送4种邮件。

@SpringBootApplication public class SpringbootMailApplication implements ApplicationRunner { @Autowired IMailService mailService; public static void main( String[] args ) { SpringApplication.run(SpringbootMailApplication.class, args); } //启动应用后直接发送邮件 @Override public void run(ApplicationArguments args) throws Exception { // TODO Auto-generated method stub mailService.sendSimpleEmail(null, null, null); mailService.sendHtmlMail(null, null, null); mailService.sendFileMail(null, null, null,null); mailService.sendPictureMail(null, null, null,null); } }

应用启动成功,并成功发送了4封邮件

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zyywff.html