c语言讲输入退回缓冲区_开始之前的结束-如何不退回输入错误的用户电子邮件...

c语言讲输入退回缓冲区

by Alex Peterson

通过亚历克斯·彼得森

开始之前的结束-如何不退回输入错误的用户电子邮件 (Over before it started — how to not bounce mistyped user emails)

I type my email address so much that it has become muscle memory. Whenever I sign up for a newsletter or make a new account on a website, that’s what I use. And I barely, if ever, double-check to see that the address I typed is actually correct.

我输入的电子邮件地址太多了,以至于已经成为肌肉记忆。 每当我注册时事通讯或在网站上创建新帐户时,这就是我所使用的。 而且我几乎(如果有的话)仔细检查一下我输入的地址是否正确。

What if my fingers slip, or I miss a key?

如果手指滑动或错过钥匙怎么办?

This is not an uncommon occurrence. It’s a big problem for websites that rely on an email address to verify new users. But it’s an even bigger problem for websites that do not rely on email address verification.

这并非罕见。 对于依赖电子邮件地址验证新用户的网站来说,这是一个大问题。 但是对于不依赖电子邮件地址验证的网站来说,这是一个更大的问题。

This results in the emails companies send out bouncing.

这导致公司发送的电子邮件被退回。

The “hard bounce” rate is the number of invalid email addresses they send out as a percentage of valid email addresses.

“硬跳”率是它们发送的无效电子邮件地址的数量占有效电子邮件地址的百分比。

有多大的问题? (How big of a problem?)

According to MailChimp’s research, the “hard bounce” rate for companies sending emails can climb over 1%, while the average rate is 0.53%. Those might not sound like big numbers, but the bounces can add up.

根据MailChimp的研究 ,发送电子邮件的公司的“硬跳”率可以攀升1%以上 ,而平均率为0.53% 。 这些听起来可能并不大,但是反弹可能会加起来。

Think of the following emails you may send your customers,

想想您可能会向客户发送的以下电子邮件,

  • welcome email

    欢迎电邮
  • verification email

    验证邮件
  • drip campaign

    滴灌运动
  • product announcements

    产品公告
  • activity notifications

    活动通知
  • App error alerts

    应用错误提示
  • weekly blog roundups

    每周博客综述

And the list goes on…

而这样的例子不胜枚举…

As your website or app scales, the number of bounced emails scales with you.

随着您网站或应用程序的扩展,退回电子邮件的数量也随之增加。

Consistently bouncing emails will start to hurt your reputation as a sender. This will make it less likely that future emails you send will be trusted.

不断反弹的电子邮件将开始损害您作为发件人的声誉。 这样可以减少您以后发送的电子邮件受到信任的可能性。

And you can’t email a user asking them to fix their information in your database if you…can’t reach them.

如果您无法联系到用户,则无法向用户发送电子邮件,要求他们在数据库中修复其信息。

Unless you’ve established a secondary communication channel beforehand, users who sign up with an invalid email address are likely to be lost forever.

除非您事先建立了辅助沟通渠道,否则使用无效电子邮件地址注册的用户可能会永远丢失。

We should fix that.

我们应该解决这个问题。

该怎么办? (What can be done?)

Generally speaking, it’s a bad idea to edit a user’s input without them knowing about it.

一般来说,在用户不知道的情况下编辑用户的输入是个坏主意。

For one thing, no machine is 100% perfect at guessing what human beansactually want. But still, if you see something, say something.

一方面,没有一台机器可以100%完美地猜测出人类的实际需求。 但是,如果您看到一些内容,请说些什么。

I’ve found that giving users a gentle suggestion when the app notices that something’s probably wrong tends to go over the best. That rule of thumb worked well at a former startup job and at the startup I’m currently building.

我发现,当应用程序发现可能存在问题时,向用户提出温和的建议可能会达到最佳效果。 这个经验法则在以前的启动工作和我正在建立的启动中都很好用。

On my website for online writing workshops, there is a simple plugin that helps prevent mistypings when a user signs up with their email address:

在我的在线写作研讨会的网站上 ,有一个简单的插件,可帮助防止用户使用其电子邮件地址注册时引起的误输入:

You can try it for yourself on the login page. I’m going to show you how to set this up on your own website.

您可以在登录页面上自己尝试。 我将向您展示如何在自己的网站上进行设置。

黄铜大头钉 (The Brass Tacks)

This article assumes you are using Browserify, webpack, or something similar to build NPM packages on your website’s front end. For example, Penmob uses the VueJS webpack installation.

本文假设您使用Browserifywebpack或类似的东西在您的网站的前端上构建NPM软件包。 例如,Penmob使用VueJS Webpack安装。

First, install the Mistyep package:

首先,安装Mistyep软件包

npm install mistyep --save

Then add it to your Log in/Sign up page:

然后将其添加到“登录/注册”页面:

var mistyep = require('mistyep');

Mistyep is a package that checks your user’s input against the most common email providers. The following code ensures that someone who mistypes “gnail” instead of “gmail” can still get in.

Mistyep是一个软件包,用于根据最常见的电子邮件提供商检查用户的输入。 以下代码可确保输入“ gnail”而不是“ gmail”的人仍然可以进入。

<input type="email" id="emailInput" />
<!-- ... -->
<script>// Get your user's email input from the login form.var emailInput = document.getElementById('emailInput').value;
// Mistyep returns the original value if no correction is found.var correctedEmail = mistyep.email(emailInput);
if (emailInput !== correctedEmail) {  // suggest the alternative spelling to the user.}</script>

It’s up to you to decide how to handle surfacing the suggestion to the user. In the GIF above, when emailInput is not equal to correctedEmail I display a box. The box contains the text Did you mean {{ correctedEmail }}?. Clicking on that box sets the original emailInput field equal to correctedEmail, which then hides the box.

由您决定如何处理向用户显示建议。 在上面的GIF中,当emailInput不等于correctedEmail我会显示一个框。 该框包含文字Did you mean {{ correctedEmail }}? 。 单击该套箱原始emailInput字段等于correctedEmail ,然后隐藏框。

Note that it takes a manual click from the user to actually apply the suggestion in this example. You’ll get into trouble pretty fast by auto-updating your database records with the suggestions that Mistyep finds.

请注意,在此示例中,需要用户手动单击才能实际应用建议。 通过使用Mistyep发现的建议自动更新数据库记录,您将很快陷入困境。

You can also use Mistyep to check against an arbitrary list of words — not just email addresses. Feel free to check out the code example and play with the live demo.

您还可以使用Mistyep检查任意单词列表-而不仅仅是电子邮件地址。 随时检查代码示例并进行现场演示

把事情简单化 (Keep it simple)

Validating email addresses is a black hole that I don’t recommend venturing too far down. Mistyep can’t catch every possible mistake (nothing can). But, it’ll provide the right suggestion to users who mistype their email address for the vast majority of cases.

验证电子邮件地址是一个黑洞 ,我不建议冒险。 Mistyep无法捕获所有可能的错误(什么也不能)。 但是,它将为大多数情况下错误输入电子邮件地址的用户提供正确的建议。

I hope you find this useful for your own app or website. I post engineering insights, writing tips, and product announcements on Twitter. For (infrequent) updates, follow me. Happy building!

希望您觉得这对您自己的应用程序或网站有用。 我在Twitter上发布工程见解,撰写技巧和产品公告。 对于(不经常)更新,请关注我 。 建设愉快!

翻译自: https://www.freecodecamp.org/news/over-before-it-started-how-to-not-bounce-mistyped-user-emails-69be32408f21/

c语言讲输入退回缓冲区

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值