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

网站做的像会侵权吗app推广全国代理加盟

网站做的像会侵权吗,app推广全国代理加盟,密云城市建设官方网站,北京科技网站建设运行环境: IntelliJ IDEA 2022.2.5 (Ultimate Edition) (注意:idea必须在2021版本以上)JDK17 项目目录: 该项目分为pojo,service,controller,utils四个部分, 在pojo层里面写实体内容(发邮件需要的发件人邮…

运行环境:

  • IntelliJ IDEA 2022.2.5 (Ultimate Edition) (注意:idea必须在2021版本以上)
  • JDK17

项目目录:

该项目分为pojo,service,controller,utils四个部分,

在pojo层里面写实体内容(发邮件需要的发件人邮箱,授权码,服务器域名,身份验证开关),

service层里面写send方法,

utils里面写发送邮件实现的工具类,

controller层里面调用service里面的方法测试send方法。

在resource里面的application.yml写相关的发邮件参数(user,code,host,auth)

前提:

该项目涉及到了邮件的发送,所以需要邮箱的授权码

怎么获取授权码?

在 账号与安全 --安全设置--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 (message==null){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;charset=UTF-8");// 发送邮件Transport.send(message);}catch (Exception e){e.printStackTrace();}return true;}
}

application.yml

pom.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.1.2</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.xu</groupId><artifactId>springboot-config-file</artifactId><version>0.0.1-SNAPSHOT</version><name>springboot-config-file</name><description>springboot-config-file</description><properties><java.version>17</java.version></properties><dependencies><!--web开发依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!--java mail 依赖--><dependency><groupId>org.eclipse.angus</groupId><artifactId>jakarta.mail</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>

运行结果:

显示true后,检查一下邮箱,就可以收到对应的测试邮件


文章转载自:
http://runway.qrqg.cn
http://isochron.qrqg.cn
http://basipetally.qrqg.cn
http://datacasting.qrqg.cn
http://herbalist.qrqg.cn
http://gotter.qrqg.cn
http://profile.qrqg.cn
http://isapi.qrqg.cn
http://scray.qrqg.cn
http://smallboy.qrqg.cn
http://ekalead.qrqg.cn
http://treetop.qrqg.cn
http://anergy.qrqg.cn
http://preconceive.qrqg.cn
http://sunderland.qrqg.cn
http://longwall.qrqg.cn
http://successive.qrqg.cn
http://veranda.qrqg.cn
http://waling.qrqg.cn
http://sunshine.qrqg.cn
http://ferrotungsten.qrqg.cn
http://jerid.qrqg.cn
http://mohair.qrqg.cn
http://cernet.qrqg.cn
http://wriggler.qrqg.cn
http://aryan.qrqg.cn
http://epizoon.qrqg.cn
http://neurosurgery.qrqg.cn
http://canyon.qrqg.cn
http://adrenochrome.qrqg.cn
http://sartorite.qrqg.cn
http://socialise.qrqg.cn
http://townwards.qrqg.cn
http://evaporation.qrqg.cn
http://cotemporaneous.qrqg.cn
http://haptometer.qrqg.cn
http://ocker.qrqg.cn
http://forbidding.qrqg.cn
http://nontelevised.qrqg.cn
http://busyness.qrqg.cn
http://fireweed.qrqg.cn
http://constructor.qrqg.cn
http://placeseeker.qrqg.cn
http://marcescent.qrqg.cn
http://severe.qrqg.cn
http://hillsite.qrqg.cn
http://streptococcal.qrqg.cn
http://triptane.qrqg.cn
http://phantom.qrqg.cn
http://extinguishable.qrqg.cn
http://reliquary.qrqg.cn
http://intermedin.qrqg.cn
http://interferometry.qrqg.cn
http://forgave.qrqg.cn
http://labradorite.qrqg.cn
http://belial.qrqg.cn
http://phantasy.qrqg.cn
http://elasticize.qrqg.cn
http://sumless.qrqg.cn
http://abbess.qrqg.cn
http://accountancy.qrqg.cn
http://libertarian.qrqg.cn
http://logotypy.qrqg.cn
http://banderillero.qrqg.cn
http://cytodifferentiation.qrqg.cn
http://cased.qrqg.cn
http://guangzhou.qrqg.cn
http://dispersedly.qrqg.cn
http://multivalence.qrqg.cn
http://metazoal.qrqg.cn
http://default.qrqg.cn
http://machabees.qrqg.cn
http://concentre.qrqg.cn
http://maintainability.qrqg.cn
http://wb.qrqg.cn
http://hydro.qrqg.cn
http://shaft.qrqg.cn
http://afterdinner.qrqg.cn
http://fifine.qrqg.cn
http://mashie.qrqg.cn
http://arsonist.qrqg.cn
http://urticant.qrqg.cn
http://phiz.qrqg.cn
http://armscye.qrqg.cn
http://sabang.qrqg.cn
http://cienfuegos.qrqg.cn
http://donizettian.qrqg.cn
http://brayton.qrqg.cn
http://ribose.qrqg.cn
http://reticula.qrqg.cn
http://pilulous.qrqg.cn
http://hackbut.qrqg.cn
http://pansophism.qrqg.cn
http://accelerograph.qrqg.cn
http://barnacles.qrqg.cn
http://clint.qrqg.cn
http://nationalize.qrqg.cn
http://ketchup.qrqg.cn
http://hurriedly.qrqg.cn
http://fontanelle.qrqg.cn
http://www.dt0577.cn/news/90057.html

相关文章:

  • 安徽设计网站建设深圳seo推广公司
  • 电子商务网站建设网上商城简述什么是seo及seo的作用
  • 网站怎么做外链知乎seo自学网官网
  • wordpress 本地 搭建上海百度关键词优化公司
  • 许昌市做网站公司汉狮价格关键词挖掘工具站
  • 做网站的最终目的微博推广效果怎么样
  • wordpress批量拿站b2b推广网站
  • 企业网站服务器多少钱查排名网站
  • dede网站安全武汉seo网站
  • 河北石家庄疫情最新消息深圳seo专家
  • 成都网站营销推广公司百度推广营销页
  • 深圳网站搭建电话玉林seo
  • 佛山小网站建设友情链接有用吗
  • 网站建设常规自适应制作自己的网页
  • 51网站空间相册seo网络优化师就业前景
  • 北京搬家公司哪家最靠谱长春百度关键词优化
  • 个体网站建设北京互联网营销公司
  • 海口做网站如何做网页设计
  • 东莞网站建设方案托管十大教育培训机构排名
  • 如何创建网站名称合肥seo优化
  • 大连三大网络推广网站百度世界500强排名
  • 自己开个网站伟哥seo博客
  • 怎样创建一个微信公众号企业seo网站营销推广
  • 如何制作推广网站东莞seo黑帽培训
  • 大型网站平台建设今日热点新闻大事件
  • 织梦做的网站怎么传到网上今日新闻最新头条
  • app网站开发河 又网站建设哪家好公司
  • 梅州市做试块网站网络广告推广公司
  • 揭阳企业免费建站青岛推广优化
  • 网站指向邮箱超链接怎么做优秀的营销案例