mailgun收发邮件

暑假小组合作做的项目java-gradesystem需要做邮箱验证,申请了mailgun帐号,准备用java实现一个发送邮件的功能 发送邮件 使用mailgun api java MailgunMessagesApi mailgunMessagesApi = MailgunClient.config(apikey) .createApi(MailgunMessagesApi.class); Message message = Message.builder() .from("STD成绩管理系统 <postmaster@yourdomain>") .to(email) .subject(subject) .text(post) .build(); MessageResponse messageResponse = mailgunMessagesApi.sendMessage("yourdomain", message); 注:apikey和yourdomain填成自己的 python def send_simple_message(): return requests.post( "https://api.mailgun.net/v3/duan-dky.me/messages", auth=("api", "apikey"), data={"from": "postmaster@yourdomain", "to": ["mail@example.com", "postmaster@yourdomain"], "subject": subject, "text": post}) javascript const apiKey = 'apikey'; const domain = 'yourdomain'; const mailgun = require('mailgun-js')({ domain, apiKey }); mailgun. messages(). send({ from: `test@${domain}`, to: email, subject: subject, text: post })....

九月 14, 2022 · 1 分钟 · 186 字 · Me

记录一次jsp与servlet之间传递表单时遇到的问题

jsp提交表单时遇到一个问题,我需要提交两个表单,但是其中一个表单嵌套在另外一个表单中,尝试了嵌套表单,但是提交失败,servlet获取不到对应的参数于是尝试了js生成一个表单提交 <div class="body-content-list"> <span class="input-name">电子邮件:</span> <input type="text" class="input-style" id="email" name="email" value="${requestScope.email}" placeholder="请填写电子邮箱地址" onchange="checkEmail()" onkeyup="value=value.replace(/[^\w\@\_\.]/ig,'')"/> <div id="chkEmail" style="font-size:12px;"></div> </div> <div class="body-content-list2"> <span class="input-name">邮箱验证:</span> <input type="text" class="input-style" id="confirmId" name="confirmId" value="${requestScope.confirmId}" placeholder="请填写邮箱验证码"/> <div class="last-info"> <span id="confirmEmail"><button type="button" class="btn btn-blue" id="confirm" style="min-width: 45px;text-align: center;font-size: 30px;background-color:#2a66e1;color: white;" onclick="sendEmail()">获取验证码</button></span> </div> <div id="chksend" style="font-size:12px;"></div> </div> 注:button的type需要设置成button,阻止提交表单,鼠标点击事件执行js代码,requestScope用于获取servlet提交的参数。 function sendEmail(){ var email=document.getElementById("email").value; var universityId=document.getElementById("universityId").value; var Urole=document.getElementById("Urole").value; let form=document.createElement('form'); //创建表单 form.action = "userServlet?action=sendEmail"; //跳转到servlet form.method = "POST"; //设置POST请求 form.innerHTML = '<input name="email" value="'+email+'">'+'\n'+'<input name="universityId" value="'+universityId+'">'+'\n'+'<input name="Urole" value="'+Urole+'">'; //表单内容 document....

九月 14, 2022 · 1 分钟 · 110 字 · Me

xray reality配置

xray安装 wget https://github.com/XTLS/Xray-core/releases/download/v1.8.1/Xray-linux-64.zip unzip Xray-linux-64.zip cp xray /usr/bin mkdir /etc/xray cp *.dat /etc/xray xray systemd服务 [Unit] Description=Xray Service Documentation=https://github.com/xtls After=network.target nss-lookup.target [Service] ExecStart=/usr/bin/xray run -config /etc/xray/config.json Environment="XRAY_LOCATION_ASSET=/etc/xray" Restart=on-failure RestartPreventExitStatus=23 LimitNPROC=10000 LimitNOFILE=1000000 [Install] WantedBy=multi-user.target 注意:若xray所在目录和geosite.dat所在目录不一致,需要设置环境变量XRAY_LOCATION_ASSET,不设置此环境变量会导致默认将geosite.dat定位至/use/bin,此目录无geosite.dat,因此服务会报错无法启动 设置systemd服务自动启动 sudo systemctl enable --now xray vless+websocket+tls和vless+nginx+grpc+tls容易被识别,不建议使用 vless reality配置 服务端 { "log": { "loglevel": "info", "access": "/var/log/xray/access.log", "error": "/var/log/xray/error.log" }, "inbounds": [ // 服务端入站配置 { "port": 443, "protocol": "vless", "settings": { "clients": [ { "id": "UUID", // 必填,执行 ....

八月 31, 2022 · 2 分钟 · 376 字 · Me

hysteria配置

由于hysteria用了udp协议,不受tcp阻断的影响,故尝试此项目。 server端 下载安装 下载 wget https://github.com/HyNetwork/hysteria/releases/download/v1.2.0/hysteria-linux-amd64 编辑配置文件config.json { "listen": ":37658", #监听端口 "protocol": "wechat-video", #流量类型,支持udp,faketcp,wechat-video "cert": "/path/to/fullchain.pem", "key": "/path/to/privkey.pem", "alpn": "h3", "auth": { "mode": "passwords", "config": ["yourpassword"] }, "up_mbps": 100, #限速,建议值不要过高,默认单位:Mbps "down_mbps": 100 } 启动hysteria ./hysteria -c config.json server 注册为systemd服务 [Unit] Description=Hysteria, a feature-packed network utility optimized for networks of poor quality Documentation=https://github.com/HyNetwork/hysteria/wiki After=network.target [Service] CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_NET_RAW AmbientCapabilities=CAP_NET_BIND_SERVICE CAP_NET_RAW NoNewPrivileges=true WorkingDirectory=/etc/hysteria Environment=HYSTERIA_LOG_LEVEL=info ExecStart=/usr/bin/hysteria -c /etc/hysteria/config.json server Restart=on-failure RestartPreventExitStatus=1 RestartSec=5 [Install] WantedBy=multi-user.target 重载systemd服务 sudo systemctl daemon-reload sudo systemctl enable --now hysteria client端 我是用的clash meta核心,它可以进行分流...

八月 29, 2022 · 1 分钟 · 110 字 · Me

自建gitlab

安装方式 我选的docker镜像,方便管理 1.拉取docker镜像 docker pull gitlab/gitlab-ee:latest 2.设置gitlab存储位置 export GITLAB_HOME=/srv/gitlab #自己设置位置 3.运行docker镜像 sudo docker run --detach \ --hostname gitlab.example.com \ #外部url,服务器域名 --publish 443:443 --publish 80:80 --publish 22:22 \ #换成自己的端口 --name gitlab \ --restart always \ #设置自动启动 --volume $GITLAB_HOME/config:/etc/gitlab:Z \ #相当于文件挂载点 --volume $GITLAB_HOME/logs:/var/log/gitlab:Z \ --volume $GITLAB_HOME/data:/var/opt/gitlab:Z \ --shm-size 256m \ gitlab/gitlab-ee:latest 4.查看gitlab运行日志 sudo docker logs -f gitlab 注:成功后即可打开浏览器输入localhost进入登录界面 5.获取管理员初始密码 sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password 注:请在24小时内修改密码,否则密码将会失效 6.gitlab配置 由于我这台服务器有nginx,需要监听80端口,因此禁用gitlab的内建nginx 禁用内建nginx nginx['enable'] = false 设置web服务器用户 web_server['external_users'] = ['www-data'] 将web服务器添加到受信任的代理列表中 gitlab_rails['trusted_proxies'] = [ '192....

八月 28, 2022 · 2 分钟 · 379 字 · Me