首页 > 其他分享 >Email邮箱验证码发送

Email邮箱验证码发送

时间:2024-03-29 14:46:28浏览次数:16  
标签:code bottom color 验证码 6px 邮箱 font margin Email

以下文件保存到/static/email.txt

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>邮箱验证码</title>
    <style>
        table {
            width: 700px;
            margin: 0 auto;
        }
        #top {
            width: 700px;
            border-bottom: 1px solid #ccc;
            margin: 0 auto 30px;
        }
        #top table {
            font: 12px Tahoma, Arial, 宋体;
            height: 40px;
        }
        #content {
            width: 680px;
            padding: 0 10px;
            margin: 0 auto;
        }
        #content_top {
            line-height: 1.5;
            font-size: 14px;
            margin-bottom: 25px;
            color: #4d4d4d;
        }
        #content_top strong {
            display: block;
            margin-bottom: 15px;
        }
        #content_top strong span {
            color: #f60;
            font-size: 16px;
        }
        #verificationCode {
            color: #f60;
            font-size: 24px;
        }
        #content_bottom {
            margin-bottom: 30px;
        }
        #content_bottom small {
            display: block;
            margin-bottom: 20px;
            font-size: 12px;
            color: #747474;
        }
        #bottom {
            width: 700px;
            margin: 0 auto;
        }
        #bottom div {
            padding: 10px 10px 0;
            border-top: 1px solid #ccc;
            color: #747474;
            margin-bottom: 20px;
            line-height: 1.3em;
            font-size: 12px;
        }
        #content_top strong span {
            font-size: 18px;
            color: #3399ff;
        }
        #sign {
            text-align: right;
            font-size: 18px;
            color: #3399ff;
            font-weight: bold;
        }
        #verificationCode {
            height: 100px;
            width: 680px;
            text-align: center;
            margin: 30px 0;
        }
        #verificationCode div {
            height: 100px;
            width: 680px;
        }
        .button {
            color: #3399ff;
            margin-left: 10px;
            height: 80px;
            width: 80px;
            resize: none;
            font-size: 42px;
            border: none;
            outline: none;
            padding: 10px 15px;
            background: #ededed;
            text-align: center;
            border-radius: 17px;
            box-shadow: 6px 6px 12px #cccccc,
            -6px -6px 12px #ffffff;
        }
        .button:hover {
            box-shadow: inset 6px 6px 4px #d1d1d1,
            inset -6px -6px 4px #ffffff;
        }
    </style>
</head>
<body>
<table>
    <tbody>
    <tr>
        <td>
            <div id="top">
                <table>
                    <tbody><tr><td></td></tr></tbody>
                </table>
            </div>
            <div id="content">
                <div id="content_top">
<img src="存放log图片路径,自行替换" style="width:150px;">
                <p></p>
	<strong>尊敬的用户:您好!</strong>
                    <strong>
                        您正在进行<span>#{explain}</span>操作,请在验证码中输入以下验证码完成操作:
                    </strong>
                    <div id="verificationCode">
                         #{code}
                    </div>
                </div>
                <div id="content_bottom">
                    <small>
                        注意:此操作为#{explain}。如非管理员请勿操作!
                        <br>(工作人员不会向你索取此验证码,请勿泄漏!)
                    </small>
                </div>
            </div>
            <div id="bottom">
                <div>
                    <p>此为系统邮件,请勿回复<br>
                        请保管好您的邮箱,避免账号被他人盗用
                    </p>
                    <p id="sign">XXX系统2.0</p>
                </div>
            </div>
        </td>
    </tr>
    </tbody>
</table>
</body>

邮件发送

// 发送方法
 String code = RandomUtil.randomNumbers(6);
 StringBuffer codeJoin = getStringBuffer(code);
 String sendInfo = getEmailSendInfo(codeJoin.toString(), verifyCodeName);
 MailUtil.send(data, verifyCodeName, sendInfo, true);
 redisUtils.set(verifyCodePre + uuid, code, RandomUtil.randomLong(300, 600));
 
 //验证码样式
 @NotNull
    private static StringBuffer getStringBuffer(String code) {
        StringBuffer codeJoin = new StringBuffer();
        for (int i = 0; i < code.length(); i++) {
            char ch = code.charAt(i);
            codeJoin.append("<button class=\"button\" >").append(ch).append("</button>");
        }
        return codeJoin;
    }
// 获取发送信息
private static String getEmailSendInfo(String code, String explain) throws Exception {
        ClassPathResource resource = new ClassPathResource("/static/email.txt");
        InputStream inputStream = resource.getInputStream();
        String sendInfo = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
        sendInfo = sendInfo.replace("#{explain}", explain).replace("#{code}", code);
        return sendInfo;
    }

标签:code,bottom,color,验证码,6px,邮箱,font,margin,Email
From: https://www.cnblogs.com/hhs-5120/p/18103797

相关文章

  • Faker库模拟数据生成,批量生成手机号,姓名,邮箱,
    一、简介Faker是一个开源的Python库,由IsaacKelly创建,旨在帮助开发者在测试和开发过程中生成伪造(模拟)数据。这个库能够生成各种类型的信息,包括但不限于姓名、地址、信用卡号、公司名称等,以及各种其他类型的模拟数据,这些数据可以用于填充数据库、创建测试账户、进行单元测试等......
  • 脚本监控重要文件,并邮箱报警
    #!/usr/bin/bash#==================================================#脚本说明#使用前请先自行配置mail配置文件/etc/mail.rc#文件末尾添加#setfrom=发送邮箱#setsmtp=smtp.163.com#setsmtp-auth-user=接收邮箱#......
  • 使用egg.js从qq发送验证码
    0.从qq获取授权码1.下载pnpminodemailer 2.service层asyncSendEmailByUserNameByUserPasswordByUserEmail(user){constnodemailer=require('nodemailer');constuser_email='abcd.com';//这里写发送者的qq号constauth_code=�......
  • Django之图形验证码
    【1】生成图片验证码依赖于pillow模块pipinstallpillow使用pillow模块在导入时使用importPIL,而不是pillow【1.1】Pillow图像生成模块fromPILimportImage,ImageDraw,ImageFont#Image:生成图片对象#ImageDraw:生成画笔对象#ImageFont:控制字体样式#图......
  • 消息sms 邮箱/手机号/push发送的方案 & 定时任务xxlJob灵活度 & 泛型和发送的模板类设
    消息sms邮箱/手机号/push发送的方案&定时任务xxlJob灵活度&泛型和发送的模板类设计1.消息sms邮箱/手机号/push发送的方案1.判断收件人地址是否为空,不为空则发送邮件。为空则不发送。可以通过该方法终止一些消息的发送。2.收件人的地址可以配置在Apollo中,直接删除该key......
  • 基于SpringBoot+Vue的商务邮箱安全系统
    运行演示:运行演示跳转开发语言:JavaJDK版本:JDK1.8(或11)服务器:tomcat数据库:mysql 5.6/5.7(或8.0)数据库工具:Navicat开发软件:idea依赖管理包:Maven代码+数据库保证完整可用,可提供远程调试并指导运行服务(额外付费)~如果对系统的中的某些部分感到不合适可提供修改服务,比如题目、......
  • HTML学习笔记5——功能性链接(打电话发邮箱)
    可以跳转至发邮箱打电话等的链接,在vscode中写完代码后右击选择OpenwithliveServer用服务器打开。这篇文章主要介绍发邮箱和用手机打电话。<--都写在body中--><--邮箱格式--><ahref="mailto:[email protected]">邮箱</a><--打电话格式--><ahref="tel:176xxxxxxxx......
  • 算术验证码&字母验证码
    /***生成验证码图片并返回给客户端*@paramkey验证码对应的key*@paramrequestHTTP请求对象*@paramresponseHTTP响应对象*@throwsException异常处理*/@RequestMapping("/captcha")publicvoidcaptcha(@RequestParamStringkey,HttpServletReq......
  • macbook使用php的fastadmin框架验证码不显示解决办法
    macbook使用php的fastadmin框架验证码不显示解决办法给php安装freetype插件freetype下载链接解压插件进入命令行工具,然后进到刚才解压的文件目录中然后执行该命令./configure--enable-static--enable-shared(没有指定prefix,.h文件默认安装到/usr/local/includ......
  • 使用Django-Simple-Captcha在Django项目加入验证码模块并自定义样式
    在Django项目中加入验证码功能,通常需要借助第三方库,比如Django-Smple-Captch、Django-reCAPTCHA、DEF-reCAPTCHA、Wagtail-Django-ReCaptcha、Django-Friendly-Captcha等。其中,Django-Smple-Captcha是一个流行的选择,它提供了一个简单而强大的Django应用,无需调用第三方API,......