当前位置: 首页 > news >正文

招工做的网站网站域名改了以后新域名301

招工做的网站,网站域名改了以后新域名301,导购网站怎么做有特色,什么是网络广告营销运行环境#xff1a; IntelliJ IDEA 2022.2.5 (Ultimate Edition) (注意#xff1a;idea必须在2021版本以上#xff09;JDK17 项目目录#xff1a; 该项目分为pojo,service,controller,utils四个部分#xff0c; 在pojo层里面写实体内容#xff08;发邮件需要的发件人邮…运行环境 IntelliJ IDEA 2022.2.5 (Ultimate Edition) (注意idea必须在2021版本以上JDK17 项目目录 该项目分为pojo,service,controller,utils四个部分 在pojo层里面写实体内容发邮件需要的发件人邮箱授权码服务器域名身份验证开关 service层里面写send方法 utils里面写发送邮件实现的工具类 controller层里面调用service里面的方法测试send方法。 在resource里面的application.yml写相关的发邮件参数usercodehostauth 前提 该项目涉及到了邮件的发送所以需要邮箱的授权码 怎么获取授权码 在 账号与安全 --安全设置--SMTP/IMAP服务 中开启服务并获取授权码 代码 pojo层 package com.xu.springbootconfigfile.pojo; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component;Component ConfigurationProperties(prefix email) public class EmailProperties {//Value(${email.user})//发件人邮箱public String user ;//Value(${email.code})//发件人邮箱授权码public String code ;//Value(${email.host})//发件人邮箱对应的服务器域名,如果是163邮箱:smtp.163.com qq邮箱: smtp.qq.compublic String host ;//Value(${email.auth})//身份验证开关private boolean auth ;public String getHost() {return host;}public void setHost(String host) {this.host host;}public boolean isAuth() {return auth;}public void setAuth(boolean auth) {this.auth auth;}public String getUser() {return user;}public void setUser(String user) {this.user user;}public String getCode() {return code;}public void setCode(String code) {this.code code;}Overridepublic String toString() {return EmailProperties{ host host \ , auth auth , user user \ , code code \ };} } service层 package com.xu.springbootconfigfile.service; public interface EmailService {boolean send(String to,String title,String content);}package com.xu.springbootconfigfile.service.impl; import com.xu.springbootconfigfile.pojo.EmailProperties; import com.xu.springbootconfigfile.service.EmailService; import com.xu.springbootconfigfile.utils.MailUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;Service public class EmailServiceImpl implements EmailService {//注入email配置信息实体类Autowiredprivate EmailProperties emailProperties;/*** param to 收件人邮箱* param title 邮件标题* param content 邮件正文* return*/Overridepublic boolean send(String to, String title, String content) {//打印email配置信息System.out.println(emailProperties);//发送邮件boolean flag MailUtil.sendMail(emailProperties,to, title, content);return flag;} }controller层 package com.xu.springbootconfigfile.controller; import com.xu.springbootconfigfile.service.EmailService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;RestController public class EmailController {//注入email配置信息实体类Autowiredprivate EmailService emailService;//测试方法RequestMapping(/send)public Boolean send(){//收件人信箱String to 邮箱号;//邮件标题String title test;//邮件正文String content 哈哈哈哈哈哈哈;//发送邮件boolean flag emailService.send(to,title,content);return flag;}}utils层 package com.xu.springbootconfigfile.utils; import com.xu.springbootconfigfile.pojo.EmailProperties; import jakarta.mail.*; import jakarta.mail.internet.InternetAddress; import jakarta.mail.internet.MimeMessage; import java.util.Properties;public class MailUtil {/*** 发送邮件* param emailProperties 发件人信息(发件人邮箱,发件人授权码)及邮件服务器信息(邮件服务器域名,身份验证开关)* param to 收件人邮箱* param title 邮件标题* param content 邮件正文* return*/public static boolean sendMail(EmailProperties emailProperties, String to, String title, String content){MimeMessage message null;try {Properties properties new Properties();properties.put(mail.smtp.host, emailProperties.getHost());properties.put(mail.smtp.auth,emailProperties.isAuth());properties.put(mail.user, emailProperties.getUser());properties.put(mail.password, emailProperties.getCode());// 构建授权信息用于进行SMTP进行身份验证Authenticator authenticator new Authenticator() {Overrideprotected PasswordAuthentication getPasswordAuthentication() {return new PasswordAuthentication(emailProperties.getUser(), emailProperties.getCode());}};// 使用环境属性和授权信息创建邮件会话Session mailSession Session.getInstance(properties, authenticator);// 创建邮件消息message new MimeMessage(mailSession);}catch (Exception e){e.printStackTrace();}//如果邮件创建失败,直接返回if (messagenull){return false;}try {// 设置发件人InternetAddress form new InternetAddress(emailProperties.getUser());message.setFrom(form);// 设置收件人InternetAddress toAddress new InternetAddress(to);message.setRecipient(Message.RecipientType.TO, toAddress);// 设置邮件标题message.setSubject(title);// 设置邮件的内容体message.setContent(content, text/html;charsetUTF-8);// 发送邮件Transport.send(message);}catch (Exception e){e.printStackTrace();}return true;} }application.yml pom.xml文件 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersionparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion3.1.2/versionrelativePath/ !-- lookup parent from repository --/parentgroupIdcom.xu/groupIdartifactIdspringboot-config-file/artifactIdversion0.0.1-SNAPSHOT/versionnamespringboot-config-file/namedescriptionspringboot-config-file/descriptionpropertiesjava.version17/java.version/propertiesdependencies!--web开发依赖--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency!--java mail 依赖--dependencygroupIdorg.eclipse.angus/groupIdartifactIdjakarta.mail/artifactId/dependency/dependenciesbuildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactId/plugin/plugins/build/project运行结果 显示true后检查一下邮箱就可以收到对应的测试邮件
http://www.tj-hxxt.cn/news/134151.html

相关文章:

  • 二级域名网站怎么建设精仿腾讯3366小游戏门户网站源码织梦最新内核带全部数据!
  • 网站管理系统 免费推广网站建设产品介绍
  • 淄博网站建设程序企微管家
  • 用j2ee作的网站兴国电商网站建设
  • 网站后台框架模版网站多服务器建设
  • 淘宝在哪个网站做推广网上企业登记注册流程
  • 做网站和游戏是如何赚钱网站设计交流
  • 北京专业网站开发公司网站建设必须要做404
  • 长沙网站制作app开发公司海安县住房和城乡建设局网站
  • 用vs2013做网站东莞公司官网推广
  • 注册自己的品牌需要多少钱seo实战密码第四版电子书
  • 建设部监理网站官网网站建设服务费怎么入账
  • 做网站系统的网站开发的书籍
  • 大连网站制作选择ls15227saas建站是什么意思
  • 济南建站公司哪有苏州做网站多少钱
  • 外贸网站如何seo思政网站建设管理自查报告
  • 无锡 网站 seo 优化怎么做试玩平台推广网站
  • 国内优秀网站欣赏国内做五金加工的订单网站
  • 茶叶网站制作模板在外国做玄幻小说网站
  • 尤溪网站开发公司如何建立网站
  • 常州网站开发培训郴州做网站的公司
  • 蛋品 东莞网站建设网站设计是用什么做的
  • 排名好的青岛网站建设营销网站建设专业服务公司
  • 洛阳网站推广怎么做永康住房城乡建设局网站
  • 免费的黄冈网站有哪些平台呢永久久微信网页版手机端
  • 电商网站开发实战视频教程深圳网站建设最专业
  • html网站开发基础siteapp wordpress
  • 做网站有什么js特效室内设计软件免费下载
  • 公司网站的建设与运营管理制度网页升级访问新域名
  • 电子商务网站建设需求概述网站制作是怎么学的