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 have an email server setup with Postfix, MySQL and Dovecot. I am hosting several virtual domains. I am moving one particular domain to Google Apps. Since, Google Apps has limitations on the number of emails you can send in day, I would like to keep the current server setup to send emails. All users would be accessing their emails using Google Apps. The websites and other applications will use the Postfix server to send emails.

I'm wondering if it is possible to disable local delivery(via Dovecot service) for this particular domain. I have searched the Internet for few hours and haven't found anything relevant. If it is possible to have this set up, I would like to know how.

share|improve this question

2 Answers 2

This is actually pretty easy. In your main.cf, you probably have two settings like this:

# map might be pgsql/hash
virtual_mailbox_domains = mysql:/etc/postfix/virtual_mailbox_domains.conf
virtual_mailbox_maps    = mysql:/etc/postfix/virtual_mailbox_maps.conf

Every incoming mail triggers (at least) two queries, one to determine if the domain in question is a virtual mailbox domain and one to see if the recipient exists within a given mailbox domain.

Let's assume the domain you moved to Google Apps is example.com. What you want to achieve is that mail addressed to your server get's forwarded to Google Apps, right? That's actually pretty easy:

transport_maps = hash:/etc/postfix/transport_maps

And in /etc/postfix/transport_maps:

example.com relay:[mailserver.google.com]

This way, mail's received for example.com will NOT be delivered using your setting of virtual_transport, but instead be forwarded to mailserver.google.com - you should, of course, use a valid Google MX for this.

This will work pretty well as long as you keep a list of valid users on your Postfix server. If you don't want to do this, then you will have to modify your virtual_mailbox_domains map/SQL query to not include example.com and instead include it in relay_domains. Since your Postfix server will have no knowledge of recipients on Google Apps, and you don't want to produce backscatter spam, you will need to use Recipient Address Verification. And since you don't want to do that for all domains, you will need to define a Restriction Class:

smtpd_restriction_classes = relay_verification
relay_verification = reject_unverified_recipient

smtpd_recipient_restrictions =
  ...
  check_recipient_access hash:/etc/postfix/relay_restrictions
  ...

And /etc/postfix/relay_restrictions would contain:

example.com relay_verification

Last but not least, make sure to have a valid SPF record that includes the Postfix server as a valid mail source for example.com.

share|improve this answer

I'm a bit confused about the start of the question but in response to if it's "possible to disable local delivery (via Dovecot service) for this particular domain" this might help:

I think inside /etc/postfix/main.cf that if you're using virtual_alias_domains = me.com you.com then just removing the domain from that line will make Postfix look remotely for delivery if DNS and /etc/hosts etc doesn't tell it otherwise. Do a DNS lookup on that domain's MX records on the Server itself to see where it thinks the MX point.

postfix reload to reload the config should set it live if that's the case.

-edit-

I see what you're after.

Actually it's pretty easy from the Google side: Settings > Accounts > edit info for your outbound e-mail address and configure the settings for authenticated outbound SMTP (this will take a few attempts most likely to get used to how it's laid out).

Then add saslauthd to Postfix and run it over TLS to encrypt the login process so Google's webmail client logs in to be allowed to punt mail through your Server (and anyone with the login and password come to that). Here's a very clear HOWTO, adjust it to your version: Postfix SASL HOWTO

This also has the advantage of your mail appearing to come from your SMTP server directly so other than your MX mentioning Google, and adding SASL's package, nothing has actually changed.

share|improve this answer
    
Thanks for the response. Let me clarify the situation. The email server is hosting several domains. Let's say example.com, example.net, example.org, etc. I have pointed the mx records for example.com to Google Apps servers. I have asked all users to access their emails using Google Apps. Since Google Apps has limitations for sending emails, our websites and applications still use SMTP of our server to send emails. These applications use SMTP authentication. Therefore, the virtual domain has to exist. The problem I am facing is, emails originating from example.net are delivered locally –  Sudheer Apr 4 '11 at 6:43
    
I would like keep the current configuration and just add one rule to it - stop delivering emails to example.com loocally and have them delivered to Google Apps servers. –  Sudheer Apr 4 '11 at 6:45
    
Could you show mail log of such delivering? –  ALex_hha Oct 4 '13 at 11:34

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.