Score:0

Is it possible to trigger a shell script on incoming emails, can it be done without services like dovecot, postix, etc?

bq flag

This question more is for learning purpose.

I'm exploring ways to develop a small email server (in + out).

I have a domain that points to my server as well as mx records and all that stuff...

I also have the open ports 25, 26, 110, 993, 995, 143, 465....

I'd like to activate a shell script on incoming email.

I have apache + php running without problem. I type my domain on a browser => I see my pages from anywhere. (that part is done).

I don't exactly know where to start...

There is tons of stuff when I search

I tried dovecot, mailhog, exim but I'm having difficulty to get them up and running.

My question is more : "is there a way to listen to port x for emails => when a email arrives => execute a script (in the rawest form possible)" ?

Paul avatar
cn flag
Sure. You can program anything, including an SMTP server, to do as little or as much as you desire.
bq flag
@Paul would you know a documentation or starting point ? python, php, .sh, do you have a recommendation? the main stuff I miss it the how to "catch" or "listen" for an incoming file .... Once I get the incoming file it will be easier...
Score:3
jp flag

You can start by reading RFC 5321 and RFC 5322 that define SMTP protocol and email message format. Once you finished with these two, you can continue reading all other email-related RFCs.

When you familiarize yourself with the depth of the rabbit hole you are going to jump into, you can try Python simple SMTPD (deprecated) or aiosmtpd. You'll also need email.parser to parse incoming emails and extracting files.

And the answers to the question "Is it possible to trigger a shell script on incoming emails, can it be done without services like dovecot, postix, etc?" are here and here (actually, I have misread the question as written "with postfix" instead of "without" but I'll leave the links anyway)

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.