DEV Community


Random mail...

brandelune profile image Jean-Christophe Helary Originally published at on ・2 min read

Sometimes a wifi service wants your mail to register on their service. Sometimes it's to grant you full access, sometimes it is just to give you a few minutes so that you get their confirmation mail and register.

In any case, you generally don't want to give your email to just about anybody. I was thinking of creating a random mail generator that creates valid "enough" mails that they pass muster when you paste them in a mail field. Because most of the time the few minutes you are granted to confirm that email are enough to just check your own mail and be done with the wifi access.

So, here it is.

use scripting additions

global mailCharacters
set mailCharacters to ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

set myName to myRandomString(10)
set myDomain to myRandomString(10)
set myExtension to myRandomString(3)

set myNewMail to myName & "@" & myDomain & "." & myExtension
set the clipboard to myNewMail

on myRandomString(n)
set myString to ""
set myLength to random number from 2 to n
repeat with i from 1 to myLength
set myString to myString & item (random number from 1 to length of mailCharacters) of mailCharacters
end repeat
end myRandomString

The script creates something like:

[between 1 and 10 characters]@[between 1 and 10 characters].[between 1 and 3 characters]

and puts it into the clipboard so that you just have to run the script, and paste in the field where you need to put a mail.

It's pretty trivial, but it is just what I need.

Also, if you're a tad conscious about security, you should use a VPN over a free wifi, but that's another story.

Mac for Translators, the discussion group...


Editor guide