SpringBoot,发送到邮箱

1.pom.xml文件

广州网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、响应式网站等网站项目制作,到程序开发,运营维护。创新互联从2013年成立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联。

org.springframework.boot spring-boot-starter-mail

2.application.properties配置

#发送邮件的配置

#用那个邮箱发送邮件 spring.mail.host=smtp.163.com #spring.mail.port=465 spring.mail.username=邮箱账号

spring.mail.password=邮箱密码 spring.mail.default-encoding=utf-8 spring.mail.properties.mail.smtp.auth=true spring.mail.properties.mail.smtp.starttls.enable=true spring.mail.properties.mail.smtp.starttls.required=true

3.实体类中

@Autowired private JavaMailSender sender; @Value("${spring.mail.username}") private String from;//邮箱名字

//邮箱 @RequestMapping("selectEmail") @ResponseBody public String selectEmail(){ System.out.println("进入"); SimpleMailMessage s=new SimpleMailMessage(); s.setFrom(from); s.setTo("123456@qq.com");//发送到那个邮箱账号 s.setSubject("标题"); s.setText("经过严格的筛选,您被确定为候选人,欢迎您来面试!"); sender.send(s); return "ok"; }

当前文章:SpringBoot,发送到邮箱
网页路径:https://www.cdcxhl.com/article36/chscsg.html

成都网站建设公司_创新互联,为您提供网站营销用户体验微信公众号云服务器网站制作外贸建站

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联