Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use node to send QQ Mail CAPTCHA

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to use node to send QQ Mail CAPTCHA". In daily operation, I believe many people have doubts about how to use node to send QQ Mail CAPTCHA. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubt of "how to use node to send QQ Mail CAPTCHA". Next, please follow the editor to study!

Activate QQ Mail POP3/SMTP service

Log in to QQ Mail's URL, go to the Settings Select account tab page and turn to the lowest level to enable this service.

Obtain QQ Mail authorization code

Build node interface service

Train of thought

Create an index.js file

Install connect, body-parser, nodemailer modules

Write and introduce the connect framework

Write and introduce bodyParser module

Introduction of nodemailer module

Start installing the plug-in

Use the cmd command prompt or Git to execute the following installation commands at once

Start writing index.js file programs

Introduce each module

Let connect = require ('connect'), / / introduce connect module bodyParser = require (' body-parser'), / / introduce body-parser parsing module nodemailer = require ('nodemailer'); / / introduce nodemailer module declaration and is scheduled to send mail function async function sendMail (text,receive) {let user = "703669046@qq.com"; / / your own mailbox let pass = "sfsdfsdfsggxcew" / / QQ Mail authorization code let to = `$ {receive} @ qq.com` / / the other party's email address let transporter = nodemailer.createTransport ({host: "smtp.qq.com", port: 587, secure: false, auth: {user: user, / / user account pass: pass, / / authorization code Get through QQ},}) Let info = await transporter.sendMail ({from: `test node sends mailbox verification code`, / / sender address to: `test verification code`, / / list of receivers subject: "test verification code", / / Subject line text: text, / / plain text body}) } write connect, body-parser parsing module var app = connect () .use (bodyParser.json ()) / / JSON parsing .use (bodyParser.urlencoded ({extended: true})) / / use () method also has an optional path string that matches the beginning of the incoming request's URL. / / use method to maintain a middleware queue cross-domain request setting.use (function (req, res, next) {/ / cross-domain processing / / Website you wish to allow to connect res.setHeader ('Access-Control-Allow-Origin',' *') / / allow any source / / Request methods you wish to allow res.setHeader ('Access-Control-Allow-Methods',' GET, POST, OPTIONS, PUT, PATCH, DELETE'); / / allow any method / / Request headers you wish to allow res.setHeader ('Access-Control-Allow-Headers',' *') / / allow any type of res.writeHead (200,{ "Content-Type": "text/plain;charset=utf-8"}); / / utf-8 transcoding next () / / the next method is a recursive call}) write and send QQ Mail CAPTCHA API .use ('/ emails', function (req, res, next) {let qqEmail= req.body.email; var obj = {code:Math.ceil (Math.random () * 1000))} Let text= `CAPTCHA: ${obj.code}. You are using the login function. The verification code provided by others may lead to account theft. Do not forward or disclose `sendMail (text,qqEmail) res.end (JSON.stringify (obj)) next ();}) set port

Connect it after var app = connect ()

.initiate (3331); start node service

Open the cmd command prompt or Git command box under the current index.js file to execute the node index.js command

Front-end module

I am using vue-cli+elementui

Html code section

Get CAPTCHA submit reset

Effect picture

Js request code part import ajax from'.. /.. / utli/request'export const getCheckCode = param = > ajax.$post ('/ emails', param | | {}) Js event part import {getCheckCode} from'. / api/form'export default {data () {return {ruleForm: {email: ", checkPass:", code: ""},} }, methods: {submitForm (formName) {this.$ refs [formName] .validate (valid = > {if (valid) {alert ("submit!");} else {console.log ("error substitutes!"); return false }});}, resetForm (formName) {this.$ refs [formName] .fields ();}, async handleCode () {let params= {email:this.ruleForm.email} let res = await getCheckCode (params) If (res.state==200) {console.log (res)}; send qq authentication to the user

Successfully received mailbox verification code

At this point, the study on "how to use node to send QQ Mail CAPTCHA" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report