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 need to forward e-mails to different mail accounts by different conditions. The aim is to create mail notification scheme for my company. I'd like to setup server on dedicated mail domain for it. Is there any software that helps to get my aim (Linux)?

Examples:

1) forward all e-mail sent to a@my-specail-domain.com to x@x, y@y, z@z (no conditions)

2) forward e-mail sent to b@my-specail-domain.com where subject contains '[finance]' to a@b and b@b

3) forward e-mail sent to b@my-specail-domain.com where subject contains '[fault]' to s@s and s2@s.

Receivers' domains are different.

P.S. Now we use Gmail filters to get this functionality, but it's unstable and hard to maintain.

share|improve this question
    
Yes, every MTA is capable of diong this, but it's probably simpler and safer to implement the logic with an MDA such as procmail. –  symcbean Dec 7 '12 at 10:29
add comment

2 Answers

up vote 2 down vote accepted

You may use procmail. It's invokation is usually integrated in your MTA, so if you just create a configuration file, it will be used.

A skeleton of the rule you may write is:

:0  # forward if finance
* ^Subject:.*[finance].*
! a@b,b@b

For more information have a look at http://userpages.umbc.edu/~ian/procmail.html

share|improve this answer
    
It's not so easy if subject header is encoded (quoted-printable). But I found some solution for this cases: benya.com/procmail/#subjectdecode –  Valera Leontyev Dec 7 '12 at 11:01
    
You are right, not that easy :-( But I still think this is the simplest solution. –  eppesuig Dec 7 '12 at 11:06
    
As the result I wrote Exim MTA filter for mail forwarding with my conditional tests. There is only one problem that still is not resolved. When sending messages from acc@gmail.com to my virtual maillist forwarded message is not returned to acc@gmail.com. But exim logs says that the message is sent. So this message disappears in some unknown place... Other tested mail services works fine without this issue. –  Valera Leontyev Dec 8 '12 at 18:37
add comment

Did you want this server just to do the forwarding, or will people be connecting to it to pick up their mail?

If you were after a fully-fledged mailserver with a lot of features, Zimbra Collaboration Suite is very good. There's an open source edition that's free, and it can do the fowarding you want server-side via the admin interface (https). Users can make use of things like a global address list for the domain if they're using Webmail or the Zimbra Desktop client (free also).

Although you said Linux, I thought I'd mention a Windows mailserver named MDaemon. It has a feature called DomainPOP which I thought was pretty strange but is exactly what you're after. http://www.redline-software.com/eng/support/docs/mdaemon/c13.php

Use DomainPOP Mail Collection (Setup DomainPOP…, or F8) to configure MDaemon to download mail from a remote POP mailbox for redistribution to your users. This feature works by using the POP protocol to download all the mail found in the ISP's POP mailbox associated with the specified logon. Once collected, the messages are parsed according to the settings provided on this dialog and then placed in user mailboxes or the remote mail queue for MDaemon to deliver, just as if the messages had arrived at the server using conventional SMTP transactions.

I worked at a place that was using that and the emails which arrive appear to be from the original sender... so when the final recipient hits Reply, it goes to the intended recipient instead of the mailbox at the forwarding point.

share|improve this answer
    
Thanks. All I need is just forwarding, no mailboxes and mail storage. Variant with DomainPOP brings unwanted delay. –  Valera Leontyev Dec 7 '12 at 10:36
add comment

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.