I run a Postfix/Dovecot mail server for personal use. There's only a handful of actual mailboxes, essentially just [email protected]
and [email protected]
.
I frequently use the virtual
file to create virtual mailboxes forwarded to [email protected]
. I have a number of these for throwaway accounts like one-time purchases from online stores, online games I want to try without worrying about ongoing spam, etc. To do so I SSH and run the following commands:
sudo vim /etc/postfix/virtual
# add a line that looks like:
# # [email protected] [email protected]
sudo postmap virtual
sudo service postfix restart
I do this with enough frequency that I'd like to automate the process to some degree. I considered simply writing a shell script that took the virtual mailbox and real mailbox as arguments and made the changes itself, but am hoping for something even more hands off.
I would like to be able to send an email from [email protected]
to some other mailbox on the server with the virtual mailbox name as the body of the message. The issue would be the sudo
calls but I can create a new user whose sole responsibility is to handle this which should handle that.
Mostly the question is this: how would I create an event that would be triggered by an email? Is there a service somewhere that does this? Can I configure either Postfix or Dovecot to listen for that email and run commands on that event?