In the end you basically have to sync two password files, or with some more type could probably use one mysql table to auth the client with postfix and then get postfix to query the same table to auth with gmail. Another idea might be to find a PAM module that authenticates against gmail.
Anyway I used this guide
http://braiden.org/?p=15
to set up the per user account relaying:
#
smtp_use_tls=yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
And create the /etc/postfix/sasl_passwd with one line (replace the user and password with your own)
smtp.gmail.com some.user@gmail.com:PASSWORD
then I set up sasldb auth on postfix so that clients have to authenticate to postfix. Postfix queries the sasldb2 file.
The disadvantage is that if you change the gmail password and want to keep everything in sync, you have to update /etc/postfix/sasl_passwd and update the /etc/sasl2db.
Here's my main.cf
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
myorigin = /etc/mailname
mydestination =
relayhost = [smtp.gmail.com]:submission
mynetworks = 127.0.0.0/8, 10.0.0.0/8
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
smtp_use_tls=yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/relayhost_map
smtpd_sasl_path = smtpd
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
#smtpd_sasl_security_options = noanonymous, noplaintext
smtpd_recipient_restrictions =
permit_sasl_authenticated,
reject_unauth_destination
--------------------------------------------
And here's some useful links:
> http://www.postfix.org/SASL_README.html
> http://www.postfix.org/postconf.5.html
> http://enc.com.au/myscripts/postfixmysql.html
> http://braiden.org/?p=15
> https://help.ubuntu.com/community/Postfix
> http://www.debianhelp.org/node/2120
> http://www.blogternals.com/2009/04/30/postfix-google-apps-gmail-smtp-relay/