Setting up a MTA (mail transfer agent) to use gmail as a smtp relay host seemed to be a daunting task for me. The amount of options you can configure postfix with would fill up a book.
I came across Matthew Hawthorne’s excellent post on how to do exactly this. I will repeat his post here, modifying it slightly for archlinux.
Step 1, let’s install postfix.
Step 2, append the following to /etc/postfix/main.cf which will configure postfix for use with gmail.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Step 3, create a file /etc/postfix/sasl_passwd and add your gmail credentials.
Step 4, create a postfix lookup table at /etc/postfix/sasl_passwd.db by running the following command.
Step 5, start the postfix daemon.
Step 6, run the following command to test.
If you set up everything correctly, you should have sent out an email out to firstname.lastname@example.org.
Bonus: you can control where your local mail gets forwarded to by creating a ~/.forward file and adding your email to the file so that local mail will get sent to your email account. Check out the man page for aliases(5) for more info.