Index of /software/postfix-gmail

[ICO]NameLast modifiedSize

[DIR]Parent Directory  -
[TXT]configure-postfix-for-gmail.sh14-Sep-2010 13:23 2.0K
[   ]sendmail-with-envelope-sender-set-from-headers27-Jan-2010 03:58 601
[TXT]create-ca-and-cert.sh25-Jan-2010 17:06 1.3K
[TXT]README.html25-Jan-2010 13:29 4.6K
[DIR]link-backup/25-Jan-2010 13:25 -

Delivering mail through gmail using postfix on Debian

Delivering mail through gmail using postfix on Debian

Google's gmail supports sending mail with any "From:" header and envelope sender (aka "return address") which you have proved that you own. (Here are instructions.) This works through the web client, but it is also possible to route such messages through gmail's SMTP servers, which means it's possible to set up postfix to route all your mail through gmail's SMTP servers, as long as you go through the process to prove ownership of each return address that you use beforehand. The point of doing this, rather than just delivering mail directly, is that gmail's servers have what I call a "respectable" reverse DNS record -- as opposed to us internet riffraff, with our "suspicious" reverse DNS records containing multiple layers of subdomains, and unseemly strings such as "adsl" or "dyn". The end result is that, by routing your mail through gmail, you will find your messages much less likely to end up in "spam" boxes.

Postfix configuration scripts

This page contains shell scripts that will configure your Debian postfix installation to deliver mail through gmail for the specified accounts. Specifically, without prompting for anything, the scripts will:

Before you run them, you need to edit the environment values at the top of the scripts. Actually, all you really need to edit is the value of ACCOUNTS in configure-postfix-for-gmail.sh; if you do that, everything should work. If you don't, you will have to edit /etc/postfix/sasl_passwd and /etc/postfix/sender_dependent_relayhost_map to use your gmail account(s) and sender address(es) instead of mine, and your password instead of the word "SECRET".

Sendmail wrapper

Also, here is a sendmail wrapper that will set an email's envelope sender (which is used by postfix to determine whether to deliver through gmail) based on the email's "From:" header. I use this in mutt so that I can change the address just by editing the "From" field in that client. It would work with any other email client that you can make use the wrapper instead of the real sendmail.

In order to use it, I saved the wrapper in a directory listed in my $PATH added the line

set sendmail=sendmail-with-envelope-sender-set-from-headers
to my .muttrc. If you are using mutt, you might also want to see this page: Profiles with Mutt. The approach described there could either complement or replace the use of my wrapper script.

TODO

Some day, perhaps, I will unify these two scripts, make them prompt for missing values rather than force the user to edit environment variables, and edit the configuration using a function that checks for existing values using "postconf" (so that the script does not depend on scanning comments to be idempotent, and so that it does not end up clobbering any non-default changes by the user). Then I might put them in a .deb...