Hacker News new | ask | show | jobs
by euoia 2116 days ago
On a similar vein, how easy is it to programmatically process emails? I receive a report every day as an email attachment that I would like to process automatically. Right now, I’m doing part where I open the email and download it manually.
4 comments

You could retrieve it from your mail server via IMAP (say with tiny program like fetchmail) and pope them through whatever program you like.

I run my own server so info stuff like this automatically as the mail comes in.

The people saying “use smtp” don’t know what they are talking about: SMTP is the protocol for delivering mail to a host. You want to process the message as or after it arrives.

I was able to process my Gmail with a simple python script that accessed email via SMTP (using smtplib, I think it was) a long time ago, it can't be too hard.

At the time I was only experimenting with it for an idea I never fully realized, creating a system for video games to automatically play games asynchronously using email instead of a server (also you could see it was your turn again just by email notifications), thus being able to survive in perpetuity as long as SMTP remained a thing, but I could see using it to do what you're suggesting as well.

The doesn't sound very difficult if you can get the email via SMTP. I'm sure there's dozens of APIs that can do it, and in the realm I'm most familiar with, I think you could use Rails' Action Mailbox to take incoming email and process it. It's overengineered for a simple task, of course.
You could use Mailgun for this: https://www.mailgun.com/email-parsing-software