Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've created an SMTP service application that archives emails by some criteria. Now I need to make postfix send a copy to my service when it receives some mail.

Most obvious way to go would be to use "content_filter = my_service". Problem is, using content_filter I will need to re-send the mail back to postfix from my service, and I don't want to do that. Is there a way to make postfix clone, not redirect, the messages to my SMTP service?

Thanks in advance.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Look into always_bcc, recipient_bcc_maps and sender_bcc_maps, either in man 5 postconf or in the official documentation. Easiest way is probably to send a copy to an address within mydestination, and using an entry in /etc/aliases (or wherever your alias_maps points to), forward those to a script which feeds them into your archiving application.

Edit: If you need an SMTP stream, set always_bcc to something like "archive@archive.local". Then add a custom transport table in main.cf:

transport_maps = hash:/etc/postfix/transport

and edit /etc/postfix/transport to include a line like:

archive.local smtp:[127.0.0.1]:5555

After executing postmap /etc/postfix/transport, you should get the raw SMTP data stream on port 5555 on you loopback interface.

share|improve this answer
    
Well, I am using the separate service application because performance is what I need here the most. And postfix documentation states that forwarding to scripts makes system work 4 times slower because it has to convert everything to non-native syntax. That's why I want to make it send the SMTP stream directly to my service application. –  Max Sep 30 '09 at 14:46
    
And yes, I forgot to mention, there seems to be no way to forward the mail with any of those commands to the service directly. –  Max Sep 30 '09 at 14:47
    
Have all mails bcc'd to, e.g., archive@archive.local. Create a transport_maps entry like "archive.local smtp:[127.0.0.1]:5555". Don't forget to read the documentation about transport tables. –  Stefan Förster Sep 30 '09 at 16:50
    
Thanks. That's exactly what I was looking for. –  Max Oct 1 '09 at 9:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.