In this handbook we will see how to install and configure a Postfix server which relays through Gmail.
Recently I had to decommission one of my local mail servers and setting up Postfix to relay through Gmail seemed to be the most viable solution.
A lot of sites out there also seem to insist on having a client certificate when relaying to Gmail, and let me tell you that this is not required as most of them say.
I do not want to have any certificates created and installed, and just want my local mail server to simply relay through Gmail.
So to summarize this handbook shows you how to configure Postfix to relay through Gmail without having any certificates.
- root access or sudo rights
Tested and verified
The setup explained in this handbook has been tested and verified on:
- FreeBSD 9.0 system
Installation of Postfix
First lets install Postfix from the FreeBSD Ports Tree.
To install Postfix execute the command below:
Configuration of Postfix
Now we can configure Postfix to relay through Gmail.
Below you will find a working main.cf file for Postfix which relays through Gmail.
Please refert to smtpd(8) man page for explanation of the configuration options used in the example configuration file.
Here is how my main.cf file looks like:
The only things you need to edit in the above configuration file in order to match your setup is:
Please edit them and save the configuration file.
Setting up Postfix permissions
Now we need to setup proper permissions for Postfix.
To do that just execute the command below:
Creating the aliases maps
In order to create the aliases maps, execute the commands below:
Authenticating to Gmail
The next thing we need to do is to be able to authenticate to Gmail using our username and password.
To do that we need to create the /usr/local/etc/postfix/sasl_passwd file with the below content:
Now hash the file, so that Postfix can use it:
Secure the password files:
Starting Postfix during boot-time
Now that we are done with the installation and configuration of Postfix, we would want that it starts during boot-time.
To do that add the following line to your /etc/rc.conf file:
And now start Postfix:
Testing it out
Now that all is done we can finally test if our setup is working well.
To do that just send a test email and check /var/log/maillog that the mail is being processed correctly.
Check in /var/log/maillog that everything is OK.
If you want to have your local relay server be used also from all machines in your network, you might want to take a look at mail/ssmtp.
Источник : http://www.unix-heaven.org/freebsd-postfix-relay-gmail
mech_list: plain login