E
E
Elvis2021-07-16 12:51:01
Python
Elvis, 2021-07-16 12:51:01

What to use for email parsing?

Hey!
Perhaps you have already encountered this, but this is my first time, tell me what to read and which way to go.
I have a VDS server. on it there is a domain and the e-mail server is organized. To view the mail, I screwed biz.mail.ru there.
Now, I have a task so that when a letter arrives at a certain mail, a bot in the telegram group writes a message. There are no problems with the bot, I can do it. The question is how to receive a new letter.
I have a couple of ideas so far.
The first is to use a simple python script to parse the number of letters in the mailbox via pop3, but here you need to set cron to, for example, every minute. Firstly, this is a so-so idea, and secondly, I would like to receive information about a new letter faster than within a minute.
The second is callbacks. However, here I don’t know how to approach this, how to set it up, and are there any callbacks for such a task at all?
The third one is essentially the same as the first one, but in an endless loop, which is also not very good for the server, I think.

What other options, where to dig and what to read?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2021-07-16
@MechanID

Since you have a separate user for this, you can add a line like
username: "|/usr/local/bin/processmail.php" to /etc/aliases,
so the body of the letter with all the headers for the username user will be sent through the pipe to the script / usr/local/bin/processmail.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question