General Information
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.
Requirements
- root access or sudo rights
Tested and verified
The setup explained in this handbook has been tested and verified on:
- FreeBSD 9.0 system
- postfix-2.9.3,1
- cyrus-sasl-2.1.25_2
Installation of Postfix
First lets install Postfix from the FreeBSD Ports Tree.
To install Postfix execute the command below:
1 |
|
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
The only things you need to edit in the above configuration file in order to match your setup is:
- myhostname
- mydomain
- myorigin
- inet_interfaces
- my_networks
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:
1 |
|
Creating the aliases maps
In order to create the aliases maps, execute the commands below:
1 2 |
|
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:
1 |
|
Now hash the file, so that Postfix can use it:
1 |
|
Secure the password files:
1 2 |
|
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:
1 |
|
And now start Postfix:
1 |
|
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.
1 |
|
Check in /var/log/maillog that everything is OK.
Further reading
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
mcedit /usr/local/lib/sasl2/smtpd.conf
pwcheck_method: saslauthd
mech_list: plain login