Using Gmail as Mail Host with Postfix (Webmin)
| filed under: postfix, webmin, ubuntu, gmailThese instructions are based on what was found at http://www.lucidlynx.com/how-to-install-postfix-to-relay-mail-through-gmail-in-ubuntu/ but have been converted to using Webmin. The only confusing part was how to add/edit the 'generic' table since that is called 'virtual' in Postfix parlance.
This assumes the user has webmin installed and understands how to log in and use it. (Usually bring it up in a browser at https://localhost:10000 )
-
Make sure that postfix is installed. In Webmin this is done by going to "System", "Software Packages" then clicking on "Package from APT" and entering "postfix". And you may want to install "mailutils" to test the mail system out.
OR, from the command line:
sudo apt-get install postfix mailutils # Choose the SMTP server mode when configuring.
If Postfix was already installed, then make sure it is installed as an SMTP (not local) mail server. That appears to be the default when installed from Webmin:
sudo dpkg-reconfigure postfix
Click on Webmin "Refresh Modules" to get Postfix to show up.
-
In Webmin click on "Servers", "Postfix Mail Server", "SMTP Authentication And Encryption".
[screenshot 1]
Enter "[smtp.gmail.com]:587 in the "Send outgoing email via host" entry box.
Check "Login as" and enter your Gmail user name and password.
-
Return to Postfix main page and click on "Virtual Domains". Add a lookup table by clicking on the "..." next to "Map specifications".
Check and enter a "Mapping file" of "/etc/postfix/generic", then click "Save". Click "Save and Apply".
Now go to the "Virtual Domains" page again and click "Add a new mapping.". Enter the local address to remote address mapping, for example "root@localhost" to "my_user@gmail.com". An entry should be added for each user that is expected to send mail.
-
Since I never figured out how to set these through Webmin, just add the following manually to the "main.cf" file.
Click on "Edit Config Files". It should be editing "/etc/postfix/mail.cf" by default. Add this line above "smtp_sasl_password_maps=..." (order of entries seems to matter):
smtp_sasl_auth_enable=yes
Add this to the bottom of the "main.cf" file and click "Save" (make sure there is a new-line at the end):
##### client TLS parameters ##### smtp_tls_loglevel=1 smtp_tls_security_level=encrypt smtp_sasl_security_options = noanonymous smtp_generic_maps = hash:/etc/postfix/generic
-
The easiest way to test sending email is to use the 'mail' program:
sudo apt-get install mailutils echo "test" | mail -s 'Test 1' user@testaddress.com # Then check the logs to see if it bounced or had a problem tail /var/log/mail.log
