简体   繁体   中英

Javascript: find confirmation link in confirmation email

I am trying to scan the body of an email for a confirmation link. I am not sure how to find the right link though.

All interesting e-mails have their link inside the href attribute of an a element, the link sometimes contains one or more of some keywords like "register", "validate", "click", "uid"... and some form of ID. Sadly all don't have those keywords and the IDs also have many different ways they can look.

Do you have any ideas how you can find the right link, maybe something I missed?

While there is no standard for how confirmation links in emails are formatted and it's almost impossible to detect all of them with 100% accuracy, but you can still cover a whole lot.

I think you're moving in the right direction. You can also look for words, if any, inside the anchor tags like; 'Confirm you email,' 'Click here to confirm.' Also the words before and after the anchor tags themselves. Don't just analyse the hrefs apart from their context.

You can go a bit further and open the links that don't fit these criteria then look for certain helping keywords. It's a bit risky, though, as some confirmation links expire after they're opened. So keep that in mind.

A bit advanced approach (and a bit out there TBH) you can apply, if none of the links in an email are identified as confirmation links, could be taking a screenshot from the email itself and someone selects where the confirmation link is then do some analysis on the position of the click then select the corresponding element and get your link. I'm not kidding! you can do it using Puppeteer in a relatively easy way!

Of course you can always use machine learning but you don't wanna go there.

And that's it, I think.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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