LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-17-2005, 08:45 PM   #1
handsomeRob
LQ Newbie
 
Registered: Jan 2005
Posts: 4

Rep: Reputation: 0
Forwarding messages to another server via procmail


Hello,

I'm trying to forward some messages to Server A and the rest to Server B. I basically have a text file of email addresses. I then grep it in procmail and see if intended recipient is in my list. If it is, the message is sent to Server A. If not, it's sent to Server B.

I read the procmail FAQ but all I get was solutions on how to forward messages per user. I want to filter each and every message that comes in and forward it to the right server. I'm thinking the global /etc/procmailrc should do the trick. But how do I forward the message to another server? AFAIK, you can only forward a message to another email address or a folder. Or can I pipe it to another program and have that program foward messages to another server?

If this is not possinble in procmail, any suggestions for alternatives solutions?
 
Old 01-17-2005, 11:40 PM   #2
jgombos
Member
 
Registered: Jul 2003
Posts: 256

Rep: Reputation: 32
I don't get it. When you forward to another email address, you are in fact forwarding it by way of server. Procmail just hands it off to sendmail, which then does the work of DNS queries to find he correct MX server, and it connects to that MX server and sends the message.

So if you are running serverB and want to forward a message to serverA for Bob, your script would look something like:

:0
* ^TO_bob@serverB.com
! bob@serverA.com
 
Old 01-18-2005, 02:27 AM   #3
handsomeRob
LQ Newbie
 
Registered: Jan 2005
Posts: 4

Original Poster
Rep: Reputation: 0
Sorry, I wasn't clear enough. Here's the scenario:

Our company has decided to ditch our email services. The problem is, the customers and ourselves have the same domain, say foobar.com.

A company offered to host our customers on their end and host their emails (Server B). But we still want to retain the domain and only have the mails of the customers go to Server B if the message is not for us. If the message is for us, the message is sent to Server B.

We have a server from another location. I will change the MX of record of foobar.com and point it there thereby accepting emails for foobar.com.

So here's what I want to do:

1. Message arrives
2. Recipient check. Is it for us?
Yes. Send message to server A
No. Send message to server B

I can't just make .procmailrc entries for each user since I'd have to add these users to the system.
 
Old 01-18-2005, 12:32 PM   #4
jgombos
Member
 
Registered: Jul 2003
Posts: 256

Rep: Reputation: 32
Procmail only supports these actions:
[list=1][*]Deliver to an Mbox[*]Deliver to a Maildir[*]Forward to an email address[*]Deliver to a program[/list=1]

I don't know much about DNS, but it seems if your clients are running their own mailserver, you should be able to forward messages to internal email addresses, which would mean creating an internal MX record somehow, so you could forward bob@foobar.com to bob@serverb.foobar.com. Is it possible to have an MX lookup on serverb.foobar.com return something different than an MX lookup on foobar.com?

Also, why would Server A be required in your case? If the mail is for "us", then deliver the message directly in the users mail spool.

If DNS cannot be setup to accommodate the other server, I think your only option is to deliver to a program using a pipe. You can probably have an action like:

| sendmail <all switches needed to deliver to specific server>

BTW- you would probably get a better answer on the procmail mailing list. Chances are, someone there has had to do this.

Last edited by jgombos; 01-18-2005 at 12:34 PM.
 
Old 01-18-2005, 06:38 PM   #5
handsomeRob
LQ Newbie
 
Registered: Jan 2005
Posts: 4

Original Poster
Rep: Reputation: 0
jgombos,

Thanks for your input. Our clients are just end-users with email-clients (eudora, outlook, etc). The reason for sending our message to server A is that the MX server will be located somewhere else from another network. We don't want our network to accept emails not for us (at least not in our list).

We want to transition to be as seamless as possible.

Thanks for the procmail tips. I guess my option is to pipe the mail to sendmail or another program.

Thanks.

Last edited by handsomeRob; 01-18-2005 at 06:39 PM.
 
Old 01-18-2005, 07:08 PM   #6
handsomeRob
LQ Newbie
 
Registered: Jan 2005
Posts: 4

Original Poster
Rep: Reputation: 0
Talking

I found the answer! Thanks jgombos for the help. The solution isn't procmail and I hope this will be useful to someone someday.

The answer is sendmail's virtusertable. Since I already have a list of email addresses that I want to re-route to Server A, I can simply do this:

In the first 3 lines, emails will be sent to serverA. The rest of the emails with @foobar.com will be sent to ServerB. The %1 is a map for whatever username the @foobar.com is.

More of it can be found here:
http://www.sendmail.org/virtual-hosting.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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: forwarding mail to remote mail account Cadmium Linux - Software 2 01-14-2010 01:05 PM
forwarding syslog messages overwrites original hostname gfizzy Linux - Software 2 10-30-2009 09:24 AM
Procmail forwarding loop jusme Linux - Software 10 02-28-2006 12:51 PM
procmail and forwarding samek Linux - Software 3 09-12-2005 08:18 AM
KMail fails forwarding messages cleidh_mor Linux - Software 5 04-03-2005 12:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:42 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