简体   繁体   English

验证使用Google Apps脚本在Google表单中输入的电子邮件

[英]Verify Email Entered in a Google Form Using Google Apps Script

My question is basically the same as the question [ here ], but the asnwer given is not detailed enough. 我的问题与[ 这里 ]的问题基本相同,但是给出的答案不够详细。 I want to have users submit an email address in a Google form. 我想让用户以Google表单提交电子邮件地址。 This email address will be used to periodically send emails to the people who have entered information. 该电子邮件地址将用于定期向输入信息的人员发送电子邮件。 However, I don't want users to be able to enter a random email address to spam people. 但是,我不希望用户能够输入随机的电子邮件地址来发送垃圾邮件。 Therefore, I want to verify that the user has entered an email address belonging to themselves, similar to things such as adding a secondary email address in Gmail. 因此,我想验证用户是否输入了属于自己的电子邮件地址,类似于在Gmail中添加辅助电子邮件地址之类的事情。 I do not want to know how to check proper syntax . 我不想知道如何检查正确的语法

To rephrase: 改写:
I want to verify that an email entered by a user belongs to that user. 我想验证用户输入的电子邮件是否属于该用户。

Generate a random verification ID 生成随机验证ID

var charactersToUse = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
//Set the length of the ID number to generate.
var varLngthID = 5;
var makePubID = '';
for (var i=0; i<varLngthID; i++) {
  var randNum = Math.floor(Math.random() * charactersToUse.length);
  makePubID += charactersToUse.substring(randNum,randNum+1);
};

and send that number to the user in the initial email. 并在初始电子邮件中将该号码发送给用户。 Then when the user gets the email, they can come back to the site, and enter the verification code. 然后,当用户收到电子邮件时,他们可以返回站点并输入验证码。 If you want to check if an email is valid without sending an email to that address, that question has been asked here: 如果您想检查电子邮件是否有效而不向该地址发送电子邮件,请在此处提出以下问题:

Stackoverflow check email without sending anything to it Stackoverflow检查电子邮件,但不发送任何内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM