views:

950

answers:

2

I am trying to write a procmail forward script, which will forward all the mails received at mydomain.com to mydomain.NET. To be more clear, if mail is to:[email protected], it should forward to: [email protected]. Like this it should forward for all corresponding emails: How Can I do this?

+2  A: 

I think what you're looking for is perhaps better implemented using sendmail. Since procmail in the case of redirection in any case just hands over the mail to sendmail.

Use the following directive in your sendmail virtual user table:

@mydomain.com %[email protected]

which effectively will map every user at mydomain.com to the remote mydomain.net

I'm not sure if something as general as the above is allowed in procmail, i've only used procmail for filtering my personal mail.

Steen
A: 

Generally speaking .procmailrc files are deployed per user. That is, user "jack" will have one and user "jill" will have a different one. With that restriction, it's not really possible to have a single .procmailrc file act on "all the mails received at mydomain.com".

However, your server might be configured to send all incoming e-mail to a single user's account. In that case, you have the very difficult task of figuring out the intended recipient of each incoming message. While that might sound simple, it is not. You can use procmail to parse the To and Cc headers, but that does not account for Bcc's and things like mailing list servers that do not include this information in the header.

See this warning and some of the suggestions given.

Steen's suggestion to use your MTA (sendmail, postfix, etc.) to do the redirection is a good one.

--
bmb

bmb