Tuesday, December 30, 2014

pcDuino3 Nano - Postfix Install and Setup via Webmin

This is another in the series documenting my setup of a new home server with the Linksprite pcDuino3 Nano.  A listing for the entire series can be found here.  More information on the pcDuino3 Nano can be found at Linksprite’s website and the pcDuino website.

The next step in setting up my home server was to setup email so that I could relay messages from the server through gmail for monitoring purposes.

This is part of my pcDuino3 Nano series of posts but it should work for webmin on other systems.

Install Postfix from Webmin

From the Webmin menu select Un-used Modules (1), scroll down and select Postfix Mail Server (2).  Then on the resulting page select Click Here to install (3).

image

This will install Postfix.

WebminPostfixInstall

Go back to the Webmin menu and select Servers (1), Postfix Mail Server (2) and then SMTP Authentication And Encryption (3).

image

Enter “[smtp.gmail.com]:587” in the Send outgoing mail box (1), then enter your user name (2) and password (3) and press Save and Apply (4).

image

Back on the Postfix Mail Server page select Virtual Domains (1).

image

Then add a mapping file by selecting the radio button (1) next to Map specification and then select “…” to the right of the box (2) and it will bring up another window.  In this window add a mapping file (3).  I used /etc/postfix/generic.  Then select Save (4) in that window and Save and Apply (5) in the original window.

image

This will take you back to the Postfix Mail Server page where you will again select Virtual Domain.  This time you want to add a new mapping (1).

image

Add a description for the mapping (1), the local username (2) and the username it maps to (3).  Then select Save Mapping (4).  You will want to setup a mapping for any user on the server that will be sending mail.  For alerting purposes root should be enough.

image

When you are done adding mappings select Save and Apply (1) to exit back to the main Postfix Mail Server page.

image

Now you want to select Edit Config Files (1).

image

You will be adding two sections to the main.cf file (1).  Then above the smtp_sasl_password_maps line add “smtp_sasl_auth_enable=yes” (2).  Then scroll to the bottom of the file.

image

At the bottom of the file add the lines below and make sure that there is a newline at the end (3).  Then select Save (4).

##### client TLS parameters #####
smtp_tls_loglevel=1
smtp_tls_security_level=encrypt
smtp_sasl_security_options = noanonymous
smtp_generic_maps = hash:/etc/postfix/generic

image

Now everything should be setup to work.  Testing is most easily done from a command prompt.  ssh to the server and log into root.  If you haven’t already you will need to install mailutils.  Then use the command below to send a test message.

root@testshares:~# apt-get install mailutils
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  mailutils-mh
The following NEW packages will be installed:
  mailutils
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 0 B/344 kB of archives.
After this operation, 910 kB of additional disk space will be used.
Selecting previously unselected package mailutils.
(Reading database ... 89273 files and directories currently installed.)

<messages removed to save space>

update-alternatives: using /usr/bin/mail.mailutils to provide /usr/bin/mailx (mailx) in auto mode.
root@testshares:~# echo "Test Message" | mail -s 'Test 1' user1@gmail.com

This message should end up in user1@gmail.com's mailbox. If it doesn’t you can use the tail command to see the log to see what happened.

root@testshares:~# tail /var/log/mail.log

Thanks to Steve Stonebraker at http://brakertech.com/configure-postfix-with-gmail-via-webmin/ for documenting these instructions.

No comments: