Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a domain that uses Google Apps for mail. Now I decided to set up my own MTA (Postfix) on VPS (running Debian squeeze). There is only a very small number (less than half a dozen) of users and some of them prefer to keep using GMail web interface (and the rest of them have local Unix accounts). So I need to relay mail for certain recipients to Google SMTP servers. At first I did the following:

  • Added altmail.mydomain.org domain alias in Google Apps.
  • Added Postfix virtual aliases for users that want GMail:

    user user@altmail.mydomain.org

  • Set up transport table:

    altmail.mydomain.org smtp:aspmx.l.google.com

It works, but it breaks SPF and I guess repeatedly relaying even legitimate mail this way doesn't do any good for the host reputation. The solution is to implement SRS (this seems to be rather tricky with Postfix) or simply rewrite envelope sender to fixed address like postmaster@mydomain.org (I am not going to get many, if at all, bounces when delivering to valid Google Apps accounts).

But then it occurred to me that if I want to keep Google SMTP servers as backup MX records anyway, returning TEMPFAIL for certain recipients will cause any RFC-compliant sender to try the next MX record and thus deliver mail to Google without ever bothering my host to relay it. Is this a legitimate way to handle mail? How many sender MTAs are going to break because of this scheme? These recipients mostly care about mail sent from major free email services (GMail, Yahoo!, Mail.Ru etc). What is the best suited status code and enhanced status code for this situation?

Is there any way to respond with 4xx immediately after RCPT TO other than writing a custom milter?

share|improve this question

1 Answer 1

Well, in case anyone is interested:

Yes, it's possible to implement this scheme without writing any milters: just use check_recipient_access with any custom response codes and messages in access(5) table.

And no, it doesn't work. At least GMail retries the highest priority MX over and over when it sees 4xx error instead of trying the next one. For now I ended up with rewriting envelope sender addresses with pcre type canonical table to postmaster@mydomain.org.

share|improve this answer

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.