How to trigger a script for any incoming mail on delivery to mailbox
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to trigger a script for any incoming mail on delivery to mailbox
I have a non-public postfix mailserver intended to receive system mails.
To make the server dynamic, I would like it to react to unknown recipiants by creating their account (by running a script, or by other means).
My setup is on CentOS7, latest postfix and dovecot and MySQL "backend".
I was thinking about using procmail to filter and "trigger" on incoming mail.
I think I need to involve master.cf to get my "${data}" variables from the incoming mail (mail address, user, domain and so on). Feel free to suggest otherwise.
If I try to use a "pipe" in master.cf, postfix simply responds by realying the mail to the script, never delivering it to the recipant mailbox.
In my script i simply test if the user (mailadress) in the incoming mail is present in the postfix database. If not, it will create it. Dovecot will create the mail folders for any new virtual mail account. If the recipiant exist, a normal local mailbox relay should occur.
Preferably I would like the first mail to be delivered to the new mailbox too. Maybe by deferring?
Also, I need to trigger a mail to notify users of arrival of new mail to their account.
The users will only reach their messages on this system by a portal, and I want to notify the portal user with a standard mail to their preferred real mailaccount (not a forward of the incoming mail), like "You have a new message at xxx.xxx.com. Please login to read"
As mentioned, the server is located in a restricted zone and is intended for this purpose only, unreachable for other systems so do not worry about security at this point. Dovecot will simply provide an imap structure.
I would appriciate any tips on configs (or other solutions entirely) to get this working.
Most solutions semes to be related to a single user and it’s $HOME folder.
I need a solution for all incoming mail to all users. All users are virtual and have no $HOME, only a maildir.
If I try to use a "pipe" in master.cf, postfix simply responds by realying the mail to the script, never delivering it to the recipant mailbox.
I would think that if you can get the mail relayed to the script, the script should be able to deliver it to the mailbox...but, isn't there going to (might) be an issue of that delivery being relayed to the script again, causing a loop?
While your problem description is fairly clear, I'm not clear on what problem you're trying to solve...why would you be receiving "system mails" addressed to "unknown recipients"? Surely you (or someone) has control of the addresses to which system emails are sent.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.