LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-25-2018, 05:58 AM   #1
geoher
LQ Newbie
 
Registered: Apr 2018
Posts: 2

Rep: Reputation: Disabled
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.

Thank's in advance,
GeoHer
 
Old 04-25-2018, 09:41 AM   #2
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,972

Rep: Reputation: 271Reputation: 271Reputation: 271
You may find better solutions, but I use inotify to respond to new webcam images at my site.
 
Old 04-25-2018, 12:02 PM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,936

Rep: Reputation: 7323Reputation: 7323Reputation: 7323Reputation: 7323Reputation: 7323Reputation: 7323Reputation: 7323Reputation: 7323Reputation: 7323Reputation: 7323Reputation: 7323
probably this helps: https://serverfault.com/questions/26...-debian#261199
 
Old 04-25-2018, 07:42 PM   #4
geoher
LQ Newbie
 
Registered: Apr 2018
Posts: 2

Original Poster
Rep: Reputation: Disabled
Hello

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.

But thank’s anyway!
 
Old 04-26-2018, 09:13 AM   #5
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by geoher View Post
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.
 
Old 04-26-2018, 12:57 PM   #6
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,972

Rep: Reputation: 271Reputation: 271Reputation: 271
inotify would work.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Procmail: aliasing all incoming mail into 1 mailbox JimArkins Linux - Server 3 06-03-2014 09:10 AM
Linux gateway router delays incoming mail delivery wsimbota Red Hat 1 04-10-2012 08:54 AM
Cent OS run script on incoming e-mail from specific (external) mail Threesa Linux - Server 1 03-21-2011 01:54 PM
reading incoming mail for script angga Programming 1 09-17-2010 04:57 AM
Can I get an incoming email to trigger a script file? davee Linux - General 2 10-16-2003 02:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration