title: Whitelist certain email addresses in postfix
body: <p>I'm trying to work out how to have postfix only allow emails through to certain email addresses.</p>
  
  <p>I had it working using the following config:</p>
  
  <pre><code>smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/access, reject
  </code></pre>
  
  <p>and then access contains</p>
  
  <pre><code>example1.com                OK
  example2.com                OK
  miles@example3.com          OK
  </code></pre>
  
  <p>This worked - mail to anything that wasn't in the whitelist was rejected by the mailserver.</p>
  
  <p>I then wanted to route all my outgoing mail via gmail, so added</p>
  
  <pre><code>relayhost = [smtp.gmail.com]:587
  smtp_sasl_auth_enable = yes
  smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
  smtp_sasl_security_options = noanonymous
  smtp_tls_CAfile = /etc/postfix/cacert.pem
  smtp_use_tls = yes
  </code></pre>
  
  <p>It now seems that postfix is ignoring the whitelist, and sending everything through to the gmail servers.</p>
  
  <p>Can anyone explain why this is happening, and what I might need to do to resolve this?</p>
  
  <p><strong>In short - I'd like all my mail sent via a gmail account, but only if the recipient address is in a whitelist.</strong></p>