Y
Y
YoungSkipper2012-01-07 21:29:46
Command line
YoungSkipper, 2012-01-07 21:29:46

How to check and pick up mail from the command line? [ubuntu][macos]?

There is a simple subtask of a large task - once an hour to pick up mail from a specific gmail box (if the mail is from a specific addressee) and if there is an attachment, then save it to a specific folder.
I already found a C++ library to quickly implement this, but I thought it was too much for such a simple task.
I went to Google to look for what can be implemented from existing tools.
All this will work on the ubuntu server, but I also want compatibility with mac os - for testing.
To my surprise, I haven't found anything yet. No, i.e. just a lot of mail, nail, mutt, sup, etc. - but all this is designed for human use, not scripts. Those. it requires a lot of preliminary settings, prescribing configs, installing certificates, and so on and so forth.
I want something simple so that you can install via apt-get (and port / homebrew on mac os) - and form one command line - which will take all the mail from a specific addressee from the mailbox and save the attachments. I do not want to produce entities such as additional configs.
What do you advise?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
YourChief, 2012-01-07
@YourChief

what about fetchmail?

V
Vladimir Chernyshev, 2012-01-08
@VolCh

Such a utility will break the Unix way :) And it consists precisely in “too many entities” - each program does one thing, but does it well.
To receive mail according to some criteria, alas, I will not advise anything (I have never faced such a task - boxes for automatic processing have always been allocated, and spam on them was rare due to the non-triviality of names, therefore, overhead due to reading all letters is not practical As an option, you can try setting up a forward of only the necessary (sender+attach) letters to a "secret" mailbox and get everything from there). But for processing received by the same fetchmail'om (saving attachments in particular), try procmail. There is an example of a similar config, it will not be difficult to adapt it to your tasks, I think, to replace one line offhand.
And if you solve the problem head-on (that is, do exactly what you need and no more operation), then, IMHO, you need to write your own pop3 client that will retrieve only what you need and not save the body of the letter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question