Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using sendmail to selectively route incoming email elsewhere

35 views
Skip to first unread message

las...@gmail.com

unread,
Oct 31, 2008, 10:18:29 AM10/31/08
to
I have a web application on a linux server -- mysite.com.

I have two types of INCOMING email --

Purpose 1. General corporate email -- employee email,
con...@mysite.com, he...@mysite.com, etc. which I would like to bounce/
relay/route (whatever the correct term is!) to my corporate email
system hosted at gmail.com using mx records

Purpose 2. Automated machine email -- nor...@mysite.com, etc. which
I would like sendmail to handle normally

How can I use sendmail to route the email based on the "to:" field,
handling normally my Purpose 2 email and bouncing/relaing/routing the
Purpose 1 email?

Frank Luedke

unread,
Oct 31, 2008, 10:25:36 AM10/31/08
to

You can configure this in the virtusertable.

con...@mysite.com myac...@gmail.com
he...@mysite.com othera...@gmail.com

If you need to address more recepients, you can use /etc/aliases

internal-list1 myac...@gmail.com, otheraccount@gmailcom

and would put this in virtusertable

con...@myite.com internal-list1


Cheers,
Frank

las...@gmail.com

unread,
Oct 31, 2008, 2:00:58 PM10/31/08
to
My gmail addresses aren't @gmail addresses. Rather they are @mysite
addresses because it's google apps for my site and not gmail -- I
definitely should have made that clear in my original post. :) Google
apps allows you to use gmail under your own domain name.

So, using your example, routing to @gmail addresse would fail because
such @gmail addresses don't exist. And, if I routed to @mysite
addresses then I'd be in a loop because 1and1 DNS would route the
@mysite address back to my website.

I guess I need sendmail to do the following:
1 Accept and treat normally certain emails (in my case, emails sent to
noreply at mysite dot com).
2 With all other emails, re-route to google apps using MX records.
For reference, the google MX records are:
aspmx.l.google.com 1
alt1.aspmx.l.google.com 5
alt2.aspmx.l.google.com 5
aspmx2.googlemail.com 10

In this sense, sendmail is acting like a smart DNS server, keeping
some emails and sending all the rest somewhere else (to google).
Perhaps sendmail can't do this?

outsider

unread,
Nov 1, 2008, 12:23:43 PM11/1/08
to
las...@gmail.com wrote in news:96dc76a1-ed28-4ae4-a952-
f53d07...@f40g2000pri.googlegroups.com:

> My gmail addresses aren't @gmail addresses. Rather they are @mysite
> addresses because it's google apps for my site and not gmail -- I
> definitely should have made that clear in my original post. :) Google
> apps allows you to use gmail under your own domain name.
>
> So, using your example, routing to @gmail addresse would fail because
> such @gmail addresses don't exist. And, if I routed to @mysite
> addresses then I'd be in a loop because 1and1 DNS would route the
> @mysite address back to my website.
>
> I guess I need sendmail to do the following:
> 1 Accept and treat normally certain emails (in my case, emails sent to
> noreply at mysite dot com).
> 2 With all other emails, re-route to google apps using MX records.
> For reference, the google MX records are:
> aspmx.l.google.com 1
> alt1.aspmx.l.google.com 5
> alt2.aspmx.l.google.com 5
> aspmx2.googlemail.com 10
>


How do you expect any mail to arrive at your server with these mx records
in place?

Lastps

unread,
Nov 2, 2008, 3:03:30 PM11/2/08
to
>
> How do you expect any mail to arrive at your server with these mx records
> in place?  
>

That is my point! DNS can only use one set of MX records. Right now
I've pointed them to private label gmail (mysite.com hosted at
gmail). However, I want to point the MX records to my own site so
that my site can process the email for my webapp but them I want to
somehow divert my employee email over to private label gmail.

So, all my webapp email (in...@mysite.com, nor...@mysite.com, etc.) is
handled by my server and my employee email (john...@mysite.com,
jane...@mysite.com) is handled by private label gmail.

Robert Bonomi

unread,
Nov 3, 2008, 1:09:44 PM11/3/08
to
In article <1838b0a3-a9d2-490a...@p31g2000prf.googlegroups.com>,

*EXACTLY*AS*DESCRIBED* it _cannot_ be done.

With some -minor- modification, however, your goal can be accomplished.

You have to have two _different_ names/domains for the two mail servers.
One name _can_ be a sub-domain of the other, e.g. --

"mail.mysite.com" {the gmail server}

"mail.corp.mysite.com" {your 'internal' mailserver}


Now, in the DNS, you need _two_ zones (one a sub-domain of the other)
with the following minimal records:

In the 'mysite.com' zone, put:
* IN MX 10 {gmail server name}
corp IN NS {DNS server name or IP address}

next, add a second zone "corp.mysite.com" with these records:
* IN MX 10 mail.corp.mysite.com
mail IN A dotted.quad.IP.addr


NOW, add 'alias' rules on the gmail mailserver that redefines
'info' as 'in...@corp.mysite.com',
'noreply' as 'nor...@corp.mysite.com',
etc.,
*while* leaving the regular 'employee' mail addresses "unaliased".


*NOW*, all the mail comes to the gmail server, which re-writes the
names for the webapp accounts to the 'corp' form, and subsequently
forwards it to "your" internal mailserver for handling. You _can_ use
just the 'mysite.com' domain on that 'internal' server, *BUT*, if you do
do so, you must be sure to declare 'mail.corp.mysite.com.' as one of the
recognized alternate names for the machine in the sendmail config files.
Otherwise, it will _reject_ the gmail forwarded mail with a very
*UNINFORMATIVE* error to the effect of 'relaying not allowed'.


You -may- be able to do things 'the other way around', where your server
receives 'all' the mail, and forwards employee accounts to gmail, but
*THAT* depends on whether or not you can tell the gmail mailserver that
is is -only- supposed to handle 'corp.mysite.com', and _not_ all of
'mysite.com'.


Snuff

unread,
Nov 3, 2008, 1:56:05 PM11/3/08
to
On Nov 2, 12:03 pm, Lastps <jasea...@gmail.com> wrote:
>
> That is my point!  DNS can only use one set of MX records.  Right now
> I've pointed them to private label gmail (mysite.com hosted at
> gmail).  However, I want to point the MX records to my own site so
> that my site can process the email for my webapp but them I want to
> somehow divert my employee email over to private label gmail.

Don't worry about DNS for the mailboxes hosted at gmail.

This would work. Hope its what you need:

Configure the DNS MX for mysite.com to route to your site/server.

Configure mailertable on your server with this one line:
mysite.com esmtp:[aspmx.l.google.com]:[alt1.aspmx.l.google.com]:
[alt2.aspmx.l.google.com]:[aspmx2.googlemail.com]

Declare mysite.com as a virtuser_domain. In your mc file you would
add:
VIRTUSER_DOMAIN(`mysite.com')

Setup your virtusertable to handle the messages you want delivered
locally. Omitting an address will cause it to route to gmail. Your
virtusertable could look like this:

loc...@mysite.com loc...@server.mysite.com
lo...@mysite.com loc...@server.mysite.com

So long as your server is already configured to handle mail for local1
and local2 your mail will go where you want. The mailertable entry
will tell sendmail where to route the messages that aren't handled by
virtusertable (during rule set 0). The colons separating the
hostnames in mailertable tell sendmail to use the entries in a MX
fashion rather than round-robin.


0 new messages