There’s a website I use all the time where the log-in mechanism involves sending a code to my e-mail address.

Anyone know of a simple way to write a script that retrieves that code? I can set up a custom e-mail address on any free provider and have all these “log-in” e-mails automatically forwarded to that. Is the best way to use something like imaplib?

Follow

The other thought I had was that I’d set up a local e-mail provider. Normally I’d be afraid of getting on an e-mail blackhole list or something, but presumably deliverability is less of an issue if you never send anything?

@pganssle Correct. And coding up a basic SMTP receiver is actually surprisingly easy. Parsing the email for the code would be more challenging.

@pganssle SMTP is just a text protocol over TCP. So, use whatever socket library you’re comfortable with and then look up the SMTP spec. Most likely, for your use case, you can ignore all the stuff about attachments and just accept basic messages and parse their contents.

Like, the first message you have to accept is a four-char “HELO”. That kind of simple.

The biggest problem you’re likely to run into is many messages are encrypted into Base64, but even then, there are a ton of libraries to decode it.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.