Skip to content
Nosce Te Ipsum
  • Home
  • About me
  • My COETAIL Blogs
    • Course 1
    • Course 2
    • Course 3
    • Course 4
  • Testimonials
    • Professional
    • Personal
Site Search

duplicate email delivery to two servers from postfix

  • September 27, 2010
  • by Muhammad
Share on Facebook
Facebook
Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin
Pin on Pinterest
Pinterest
Share on Reddit
Reddit
Email this to someone
email
Share on StumbleUpon
StumbleUpon
Digg this
Digg

You can easily have a postfix relay server to manage emails for more than one domains but the aim here is to deliver an email coming in for one domain to two different servers. It is basically duplicating an email.

method 1:

Automatic BCC recipients

After applying the canonical and masquerade mappings, the cleanup(8) daemon can generate optional BCC (blind carbon-copy) recipients. Postfix provides three mechanisms:

always_bcc = address
Deliver a copy of all mail to the specified address. In Postfix versions before 2.1, this feature is implemented by smtpd(8), qmqpd(8), or pickup(8).
sender_bcc_maps = type:table
Search the specified “type:table” lookup table with the envelope sender address for an automatic BCC address. This feature is available in Postfix 2.1 and later.
recipient_bcc_maps = type:table
Search the specified “type:table” lookup table with the envelope recipient address for an automatic BCC address. This feature is available in Postfix 2.1 and later.

Note: automatic BCC recipients are produced only for new mail. To avoid mailer loops, automatic BCC recipients are not generated for mail that Postfix forwards internally, nor for mail that Postfix generates itself.

Automatic BCC recipients (including always_bcc) can be turned off selectively for mail received by smtpd(8), qmqpd(8), or pickup(8), by overriding main.cf settings in the master.cf file. This feature is available in Postfix version 2.1 and later.

Example:

/etc/postfix/master.cf:
    127.0.0.1:10026    inet  n      -      n      -      -     smtpd
        -o receive_override_options=no_address_mappings

Note: do not specify whitespace around the “=” here.

method 2:
Install
MailScanner and Spamassassin

Create a ruleset for non-spam emails

Ex.
{
To: domain.com deliver store-/var/archive/incoming/domain_com forward archive@domain.com
From: domain.com deliver store-/var/archive/outgoing/domain_com forward archive@domain.com
}

This will take any mail from domain.com deliver it to the intended user, store the email in a file in /var/archive/<direction>/domain_com and then send it to another email account.

If you want it to go to a seperate mail server you can edit the transport map for that subdomain that the mail is forwarded to point to another sub-domain and change “forward archive@domain.com” to “forward archive@archive.domain.com”.

You can also do per user for the ruleset so you could do something like this.

Ex.
{
To: user1@domain.com deliver store-/var/archive/incoming/domain_com forward user1@archive.domain.com
From: user1@domain.com deliver store-/var/archive/outgoing/domain_com forward user1@archive.domain.com
}

If you are really that concerned about it being the same “domain” the servers can “think” they are both part of the same domain but the server sending them the mail doesn’t have to. Just edit the hosts file of the server that is splitting the mail so it thinks it is on a subdomain.

method 3:

What you *should* look at is the content_filter. The content filter is a simple server program that listens to a specific port and gets mail from postfix. It then filters whatever needs filtering, and optionally sends stuff back to the postfix with various options included. In the filter program, I would then simply forward the mail to the new server, and feed the mail back into to local postfix for delivery. This way, you can have a sort of postfix tee Have a look at amavisd for how to implement this. Also Perl programming comes in handy in this case.

In general your content_filter would be something like
====<main.cf>====
content_filter=smtp-tee:127.0.0.1:10024
====<master.cf>====
smtp-tee unix – – y – 2 smtp -o smtp_data_done_timeout=1200

127.0.0.1:10025 inet n – n – – smtpd
-o content_filter=
-o my_networks=127.0.0.0/8
-o smtpd_recipient_restrictions=permit_mynetworks,rej ect
===========

This way, the server you implement listens on port 10024, gets the mail, and simply forwards it to port 25 on your new mail server. After that, it forwards it to port 10025 on the local server for further processing, that is: delivery.

Also, if you already have an antispam/antivirus configured, you can chain these elements (spamfilter and tee) by setting the content_filter parameter of one postfix input port to the other content_filter. So you can have antispam/antivirus checking done before you filter the mail to your tee.

method 4 (reported to not work in certain cases:

You can get postfix to send a copy of all email by adding this to your main.cf:

milter_default_action = tempfail
smtpd_milters = inet:ip_address_of_second_serverort_number

Our looks like:

milter_default_action = tempfail
smtpd_milters = inet:10.0.0.11:8092

Share on Facebook
Facebook
Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin
Pin on Pinterest
Pinterest
Share on Reddit
Reddit
Email this to someone
email
Share on StumbleUpon
StumbleUpon
Digg this
Digg
هور وى نيوان هو
ClearOS: squid with VLANS
Muhammad
duplicate email postfix relay smtp

Related articles

Preventing Backscatter from relay SMTP…

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Follow Me!

Follow Me On TwitterFollow Me On LinkedInFollow Me On PinterestFollow Me On About.meFollow Me On Wordpress
May 2025
M T W T F S S
« Oct    
 1234
567891011
12131415161718
19202122232425
262728293031  

2009 2010 2011 Amelie apache beijing birthday clearos crèpes debian december 2009 dubai email february firewall guide holidays ill install internet kuala lumpur linux list mac maheen mobile october 2009 outlook Pakistan raspberry raspberry pi router search Sharepoint smtp snow spring ubuntu unix VLAN VPN windows 7 winter xian Zimbra

WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

Categories

Licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
Theme by Colorlib Powered by WordPress
  • Home
  • About me
  • My COETAIL Blogs
  • Testimonials