{{ v.name }}
{{ v.cls }}类
{{ v.price }} ¥{{ v.price }}
1.pop.xml
#邮件配置:spring.mail.host=smtp.qq.comspring.mail.username=发送人的邮箱@qq.comspring.mail.password=密码(授权码,具体看下面的操作)spring.mail.properties.mail.smtp.auth=truespring.mail.properties.mail.smtp.starttls.enable=truespring.mail.properties.mail.smtp.starttls.required=truespring.mail.properties.mail.smtp.ssl.enable=true
先看看qq邮箱或者其他邮箱pop3服务开了没有。没有的去开启
3.测试类,只实现简单的邮件
importorg.junit.test;importorg.junit.runner.runwith;importorg.springframework.beans.factory.annotation.autowired;importorg.springframework.boot.test.context.springboottest;importorg.springframework.mail.javamail.javamailsender;importorg.springframework.mail.javamail.mimemessagehelper;importorg.springframework.test.context.junit4.springrunner;importjavax.mail.internet.mimemessage;@runwith(springrunner.class)@springboottestpublicclassdemoapplicationtests{@autowiredjavamailsendersender;@testpublicvoidsendsimplemail()throwsexception{mimemessagemessage=null;booleanflag=true;try{message=sender.createmimemessage();mimemessagehelperhelper=newmimemessagehelper(message,true);helper.setfrom("发送人的邮箱@qq.com");helper.setto("接受人的邮箱@qq.com");helper.setsubject("邮件主题");helper.settext("内容");sender.send(message);}catch(exceptione){flag=false;system.out.println(e);}system.out.println("flag:"+flag);}}4.接收结果,图片就不马赛克了,不要乱搞哦