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

做网站必须要文网文吗开发公司和建材商促销活动

做网站必须要文网文吗,开发公司和建材商促销活动,企业微信开通流程,重庆网红景点洪崖洞已挤满游客发送邮件#xff1a;SMPT、MIME#xff0c;是一种基于推的协议#xff0c;通过SMPT协议将邮件发送至邮件服务器#xff0c;MIME协议是对SMPT协议的一种补充#xff0c;如发送图片附件等 接收邮件#xff1a;POP、IMAP#xff0c;是一种基于拉的…发送邮件SMPT、MIME是一种基于推的协议通过SMPT协议将邮件发送至邮件服务器MIME协议是对SMPT协议的一种补充如发送图片附件等 接收邮件POP、IMAP是一种基于拉的协议收件人通过POP协议从邮件服务器拉取邮件 账号准备mail 客户端设置说明:参考官方Gmail帮助 一、依赖 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdparentartifactIdspringboot-demo/artifactIdgroupIdcom.et/groupIdversion1.0-SNAPSHOT/version/parentmodelVersion4.0.0/modelVersionartifactIdmail/artifactIdpropertiesmaven.compiler.source8/maven.compiler.sourcemaven.compiler.target8/maven.compiler.target/propertiesdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-autoconfigure/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-mail/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-thymeleaf/artifactId/dependency/dependencies/project二、配置文件和启动类 application.properties #这里以qq邮箱为例 # qq邮箱服务器 spring.mail.hostsmtp.qq.com # 你的qq邮箱账户 spring.mail.usernameyourAccountqq.com # 你的qq邮箱第三方授权码 spring.mail.passwordyourPassword # 编码类型 spring.mail.default-encodingUTF-8 spring.thymeleaf.prefixclasspath:/template/SpringBootApplication public class DemoApplication {public static void main(String[] args) {SpringApplication.run(DemoApplication.class, args);} }三、MailUtil.java Service public class MailUtils{// 日志private final Logger logger LoggerFactory.getLogger(MailUtils.class);Value(${spring.mail.username}) //注入 application.properties中指定的用户名private String from;Autowired //用于发送文件private JavaMailSender mailSender;//发送普通文本邮件public void sendSimpleMail(String to,String subject,String content){SimpleMailMessage message new SimpleMailMessage();message.setTo(to);//收信人message.setSubject(subject);//主题message.setText(content);//内容message.setFrom(from);//发信人mailSender.send(message);}//发送html邮件public void sendHtmlMail(String to, String subject, String content){//使用MimeMessageMIME协议MimeMessage message mailSender.createMimeMessage();MimeMessageHelper helper;try {helper new MimeMessageHelper(message, true);helper.setFrom(from);helper.setTo(to);helper.setSubject(subject);helper.setText(content, true);//true代表支持htmlmailSender.send(message);logger.info(发送HTML邮件成功);} catch (MessagingException e) {e.printStackTrace();logger.error(发送HTML邮件失败, e);}}//发送带附件的邮件public void sendAttachmentMail(String to, String subject,String content, String filePath){// 日志logger.info(发送带附件邮件开始{},{},{},{}, to, subject, content, filePath);MimeMessage message mailSender.createMimeMessage();MimeMessageHelper helper;try {helper new MimeMessageHelper(message, true);//true代表支持多组件如附件图片等helper.setFrom(from);helper.setTo(to);helper.setSubject(subject);helper.setText(content, true);FileSystemResource file new FileSystemResource(new File(filePath));String fileName file.getFilename();helper.addAttachment(fileName, file);//添加附件可多次调用该方法添加多个附件mailSender.send(message);logger.info(发送带附件邮件成功);} catch (MessagingException e) {logger.error(发送带附件邮件失败, e);}}//发送带图片的邮件public void sendInlineResourceMail( String to, String subject, String content,String rscPath, String rscId){// 日志logger.info(发送带图片邮件开始{},{},{},{},{}, to, subject, content, rscPath, rscId);MimeMessage message mailSender.createMimeMessage();MimeMessageHelper helper;try {helper new MimeMessageHelper(message, true);helper.setFrom(from);helper.setTo(to);helper.setSubject(subject);helper.setText(content, true);FileSystemResource res new FileSystemResource(new File(rscPath));helper.addInline(rscId, res);//重复使用添加多个图片mailSender.send(message);logger.info(发送带图片邮件成功);} catch (MessagingException e) {logger.error(发送带图片邮件失败, e);}} }四、邮件模板 !DOCTYPE html html langen xmlns:thhttp://www.thymeleaf.org headmeta charsetUTF-8title邮件模板/title /head body 您好感谢您的注册这是一封验证邮件请点击下面的链接完成注册感谢您的支持br a href# th:href{http://www.bestbpf.com/register/{id}(id${id})}激活账户/a /body /html测试 RunWith(SpringRunner.class) SpringBootTest(classes DemoApplication.class) public class SpringBootApplicationTest {AutowiredMailUtils mailUtils;Autowiredprivate TemplateEngine templateEngine;/*** 指定模板发送邮件*//*** 指定模板发送邮件*/Testpublic void testTemplateMail() {//向Thymeleaf模板传值并解析成字符串Context context new Context();context.setVariable(id, 001);String emailContent templateEngine.process(emailTemplate, context);mailUtils.sendHtmlMail(zhaokuii11163.com, 这是一个模板文件, emailContent);}/*** 发送简单纯文本邮件*/Testpublic void sendSimpleMail() {mailUtils.sendSimpleMail(zhaokuii11163.com, 发送邮件测试, 大家好这是我用springboot进行发送邮件测试);}/*** 发送HTML邮件*/Testpublic void sendHtmlMail() {String content htmlbodyh3font color\red\ 大家好这是springboot发送的HTML邮件 /font/h3/body/html;mailUtils.sendHtmlMail(zhaokuii11163.com, 发送邮件测试, content);}/*** 发送带附件的邮件*/Testpublic void sendAttachmentMail() {String content htmlbodyh3font color\red\ 大家好这是springboot发送的HTML邮件有附件哦 /font/h3/body/html;String filePath your file path;mailUtils.sendAttachmentMail(zhaokuii11163.com, 发送邮件测试, content, filePath);}/*** 发送带图片的邮件*/Testpublic void sendInlineResourceMail() {String rscPath your picture path;String rscId 001;String content htmlbodyh3font color\red\ 大家好这是springboot发送的HTML邮件有图片哦 /font/h3 img src\cid: rscId \/body/html;mailUtils.sendInlineResourceMail(zhaokuii11163.com, 发送邮件测试, content, rscPath, rscId);} }
http://www.pierceye.com/news/553785/

相关文章:

  • 广州优秀网站建设怎么寻找国外客户资源
  • 松江新城投资建设集团有限公司网站华能电子商务平台
  • 网站建设设计制作公司微网站微商城
  • 长宁企业网站建设个人做外贸怎么做
  • 饲料 东莞网站建设免费推广app
  • 手机平台网站开发品牌网站设计首选
  • 哪些网站可以做调查赚钱图片生成软件
  • 网站空间的管理wordpress vip system
  • 新思维网站北京住房建设部网站首页
  • 温州网站制作套餐麒麟网站建设
  • 淘宝接单做网站wordpress能做企业网站吗
  • 网站建设运营公众号运营合同app网站开发书籍下载
  • 网站seo流程网站开发开账务处理
  • 婚介网站方案长沙网络公司电话
  • 自助网站搭建系统做网站接电话一般要会什么
  • 雷州网站建设公司网站建设与管理说课ppt
  • 问答类网站怎么做wordpress 调取页面缩略图
  • 做电影资源网站手机版wordpress实例配置
  • 广西网站建设方案品牌官网方案
  • 游戏工作室网络组建方案seo81
  • 搭建个人网站的步骤温州专业微网站制作价格
  • 网站怎么做充值系统php图书管理系统网站开发
  • 多商家网站建设自助建站系统源码 资源网
  • 广州番禺网站制作公司哪家好文章网站建设
  • 漯河网站建设e辽宁身营商环境建设局网站
  • 营销网站建设套餐企业信息公示管理系统
  • 网站布局设计排版网站外部链接做多少合适呢
  • 成品网站 源码1688上海网站建设 找德华专业
  • 网站建设费用申报佛山电脑培训班哪里有
  • 免费网站服务器厦门网站建设推广哪家好